#include
#include
#include
#include
using namespace std;
string geDigit[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 numtoStr[170];
map<string, int> strtoNum;
void init(){
for(int i = 0; i < 13; i++){
numtoStr[i] = geDigit[i];
strtoNum[geDigit[i]] = i;
numtoStr[13 * i] = tenDigit[i];
strtoNum[tenDigit[i]] = 13 * i;
}
for(int i = 1; i < 13; i++){
for(int j = 1; j < 13; j++){
string str = tenDigit[i] + " " + geDigit[j];
numtoStr[13 * i + j] = str;
strtoNum[str] = 13 * i + j;
}
}
}
int main(){
init();
int N;
scanf("%d%*c",&N);
while(N--){
string str;
getline(cin, str);
if(str[0] >= '0' && str[0] <= '9'){
int num = 0;
for(int i = 0; i < str.length(); i++){
num = num * 10 + (str[i] - '0');
}
cout << numtoStr[num] << endl;
}else{
cout << strtoNum[str] << endl;
}
}
return 0;
}