import java.util.Scanner;
public class Main{
static String[] names = {"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec",
"tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"
};
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();//过滤回车符
while (n-- > 0) {
String line = sc.nextLine();
char c = line.charAt(0);//通过首字符来判断该行是单词还是数字
if (c <= '9') {//如果该行是数字
int a = Integer.parseInt(line);
if (a <= 12) {
System.out.println(names[a]);//一个单词就能表示
} else {
String res = names[12 + a / 13];
if (a % 13 != 0) {//a不是13的整数倍,说明需要两个单词表示
res += " " + names[a % 13];
}
System.out.println(res);
}
} else {//该行是单词
String[] words = line.split(" ");
int res = 0;
for (String word : words) {
res += get(word);
}
System.out.println(res);
}
}
}
private static int get(String word) {//将单词转为数字
for (int i = 0; i < names.length; i++) {
if (word.equals(names[i])) {
if (i <= 12) return i;
return (i - 12) * 13;
}
}
return -1;
}
}