#include <bits/stdc++.h>
using namespace std;
string unitDigit[13] ={"tret","jan","feb","mar","apr","may","jun","jly","aug","sep","oct","nov","dec" };
string tenDigit[13] = {"tret","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
string num2str[180];
map<string,int> str2num;
void initialNum()
{
//个位是0的和十位是0的单独讨论
for(int i=0;i<13;i++)
{
//十位是0
num2str[i] = unitDigit[i];
str2num[unitDigit[i]] = i;
//各位是0
num2str[13*i] = tenDigit[i];
str2num[tenDigit[i]] = 13*i;
}
//i代表个位 j代表十位
for(int i=1;i<13;i++)
{
for(int j=1;j<13;j++)
{
string str = tenDigit[i] + " " + unitDigit[j];
num2str[13*i+j] = str;
str2num[str] = 13*i+j;
}
}
}
int main()
{
initialNum();
int n;
cin >> n;
getchar();
for(int i=0;i<n;i++)
{
string str;
getline(cin,str);
if(str[0] >= '0' && str[0] <= '9')
{
int num=0;
for(int j=0;j<str.length();j++)
{
num = num*10 + str[j]-'0';
}
cout << num2str[num] << "\n";
}
else
{
cout << str2num[str] << "\n";
}
}
return 0;
}