#include<bits/stdc++.h>
using namespace std;
string numTostr[170];
map<string,int> strTonum;
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"};
void Init() {
for(int i=0; i<13;i++) {
numTostr[i]=unitDigit[i];
strTonum[unitDigit[i]]=i;
numTostr[i*13]=tenDigit[i];
strTonum[tenDigit[i]]=i*13;
}
for(int i=1;i<13;i++){
for(int j=1;j<13;j++){
string str=tenDigit[i]+" "+unitDigit[j];
numTostr[i*13+j]=str;
strTonum[str]=i*13+j;
}
}
}
int main() {
Init();
int n,x;
cin>>n;
cin.ignore();
string s;
for(int i=0;i<n;i++){
getline(cin,s);
if('0'<=s[0]&&s[0]<='9'){
x=stoi(s);
cout<<numTostr[x]<<endl;
}else{
cout<<strTonum[s]<<endl;
}
}
return 0;
}