#include <cstdio>
#include <cstring>
char s1[][5] = {"", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
char s2[][4] = {"", "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
int change(char a[4]){
int b;
for(int i = 1; i < 13; i++){
if(strcmp(s1[i], a) == 0) b = i;
else if(strcmp(s2[i], a) == 0) b = i * 13;
}
return b;
}
int main(){
int n, temp;
char str[10];
scanf("%d\n", &n);
while(n--){
scanf("%[^\n]", str);
getchar();
if(str[0] >= '0' && str[0] <= '9'){ //如果是数字,则转化成火星文
sscanf(str, "%d", &temp);
if(temp == 0) printf("tret");
else{
printf("%s", s2[temp / 13]);
if(temp / 13 != 0 && temp % 13 != 0) printf(" ");
printf("%s", s1[temp % 13]);
}
if(n > 0) printf("\n");
}else{ //如果是火星文,则转换成数字
if(strlen(str) == 4) printf("0"); //四个字符的只能是零
else if(strlen(str) < 4){
printf("%d", change(str));
}else{ //由至少两个火星文组成的情况
char s1[4], s2[4];
sscanf(str, "%s %s", s1, s2);
printf("%d", change(s1) + change(s2));
}
if(n > 0) printf("\n");
}
}
return 0;
}
02-26
249
09-10
1158
09-10
861