1415 {
1416 string abc[13] = {"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
1417 string abc2[13] = {"tret", "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
1418 unordered_map<string, int> um;
1419 unordered_set<string> us2;
1420 for(int i = 0; i < 13; i++) {
1421 us2.insert(abc2[i]);
1422 um[abc[i]] = i;
1423 um[abc2[i]] = i;
1424 }
1425 int n;
1426 cin >> n;
1427 char cccc[16];
1428 cin.getline(cccc, 16);
1429 while(n-- != 0) {
1430 auto *cstr = new char[1024];
1431 cin.getline(cstr, 1024);
1432 stringstream ss;
1433 ss << cstr;
1434 if(isdigit(ss.peek()) != 0) {
1435
1436 unsigned long long num;
1437 ss >> num;
1438 vector<string> output;
1439 bool flag = true;
1440 if(num == 0) {
1441 cout << "tret";
1442 } else {
1443 while(num != 0) {
1444 if(flag) {
1445 if(num % 13 != 0) {
1446 output.push_back(abc[num % 13]);
1447 }
1448 flag = false;
1449 } else {
1450 output.push_back(abc2[num % 13]);
1451 }
1452 num /= 13;
1453 }
1454 for(auto it = output.rbegin(); it != output.rend(); ++it) {
1455 cout << *it;
1456 if(it + 1 != output.rend()) {
1457 cout << ' ';
1458 }
1459 }
1460 }
1461 } else {
1462
1463 int b = 0;
1464 for(int i = 0; cstr[i] != '\0'; i++) {
1465 if(cstr[i] == ' ') {
1466 b++;
1467 }
1468 }
1469 b++;
1470 string str;
1471 unsigned long long num = 0;
1472 while(b != 0) {
1473 ss >> str;
1474 num += um[str] * pow(13, --b);
1475 }
1476 if(us2.contains(str)) {
1477 num *= 13;
1478 }
1479 cout << num;
1480 }
1481 delete[] cstr;
1482 if(n != 0) {
1483 cout << endl;
1484 }
1485 }
1486 return 0;
1487 }