import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(bf.readLine());
String[] s1 = { "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec" };
String[] s2 = { "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou" };
for (int i = 0; i < n; i++) {
String s = bf.readLine();
int r = 0;
int a1, a2;
if (s.matches("[0-9]{1,}")) {
r = Integer.valueOf(s);
if (r == 0) {
System.out.println("tret");
continue;
}
if (r < 13) {
a1 = r % 13;
System.out.println(s1[a1 - 1]);
}
if (12 < r && r < 169) {
a2 = r / 13;
a1 = r - a2 * 13;
if (a1 == 0) {
System.out.println(s2[a2 - 1]);
} else {
System.out.println(s2[a2 - 1] + " " + s1[a1 - 1]);
}
}
} else {
if (s.equals("tret")) {
System.out.println(0);
continue;
}
String[] split = s.split(" ");
if (split.length != 1) {
a1 = getIndex(s1, split[1]);
a2 = getIndex(s2, split[0]);
System.out.println(a2 * 13 + a1);
} else {
a1 = getIndex(s1, split[0]);
a2 = getIndex(s2, split[0]);
if (a1 != 0) {
System.out.println(a1);
} else {
System.out.println(a2 * 13);
}
}
}
}
}
public static int getIndex(String[] arr, String value) {
for (int i = 0; i < arr.length; i++) {
if (arr[i].equals(value)) {
return i + 1;
}
}
return 0;
}
}
PAT_B_1044_Java(20分)
最新推荐文章于 2020-07-18 18:54:32 发布