#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
const vector<string> unit = {"tret", "jan", "feb", "mar", "apr", "may", "jun",
"jly", "aug", "sep", "oct", "nov", "dec"}; // NOLINT
const vector<string> ten = {"tret", "tam", "hel", "maa", "huh", "tou", "kes",
"hei", "elo", "syy", "lok", "mer", "jou"}; // NOLINT
int main()
{
map<string, int> str2num;
map<int, string> num2str;
for (int i = 0; i < 13; ++i) {
num2str[i] = unit[i]; // 个位为[0, 12],十位为0
str2num[unit[i]] = i;
num2str[i * 13] = ten[i]; // 十位为[0, 12], 个位为9
str2num[ten[i]] = i * 13;
}
for (int i = 1; i < 13; ++i) {
for (int j = 1; j < 13; ++j) {
string str = ten[i] + " " + unit[j];
num2str[i * 13 + j] = str;
str2num[str] = i * 13 + j;
}
}
int n;
cin >> n;
cin.get();
while (n--) {
string str;
getline(cin, str);
if (str[0] >= '0' && str[0] <= '9') { // 是数字
int num = stoi(str);
cout << num2str[num] << endl;
} else {
cout << str2num[str] << endl;
}
}
return 0;
}