打表
#include<bits/stdc++.h>
using namespace std;
string low[13]={"tret","jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
string high[13]={"tret","tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
map<string,int>strtoint;
map<int,string>inttostr;
int n;
void init()
{
for(int i=0;i<13;i++)strtoint[low[i]]=i,inttostr[i]=low[i];
for(int i=1;i<13;i++)inttostr[i*13]=high[i],strtoint[high[i]]=i*13;
for(int i=1;i<13;i++)
{
for(int j=1;j<13;j++)
{
int num=i*13+j;
string s=high[i]+" "+low[j];
strtoint[s]=num;
inttostr[num]=s;
}
}
}
int main()
{
init();
int n;
scanf("%d",&n);
getchar();
while(n--)
{
string s;
getline(cin,s);
if(s[0]>='0'&&s[0]<='9')
{
int num=0;
for(int i=0;i<s.length();i++)num=num*10+s[i]-'0';
cout<<inttostr[num]<<endl;
}
else cout<<strtoint[s]<<endl;
}
return 0;
}