#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char h_month[19][7]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen",
"yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char t_date[20][9]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk",
"ok","chuen","eb", "ben","ix","mem","cib","caban","eznab","canac","ahau"};
void convert(void)
{
int date,month,year;
int total_days;
char c_month[7];
scanf("%d.%s%d",&date,c_month,&year);
for(int p=0;p<19;p++)
if(!strcmp(c_month,h_month[p]))
{ month=p; break; }
total_days=year*365+month*20+date;
int o_date_dig,o_date_name,o_year;
o_year =total_days/260;
o_date_dig =(total_days%260)%13+1;
o_date_name=(total_days%260)%20;
printf("%d %s %d\n",o_date_dig,t_date[o_date_name],o_year);
}
int main()
{
long int n,i;
scanf("%ld",&n);
printf("%ld\n",n);
void convert(void);
for (i=0;i<n;i++)
convert();
return 0;
}