package me.yukicoder.lv1; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class No0405 { public static void main(String[] args) { try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) { String[] input = br.readLine().split(" "); String[] roman = { "I", "II", "III", "IIII", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII" }; // いま何時? int hour = 1; for (int i = 0; i < roman.length; i++) { if (input[0].equals(roman[i])) { hour = i + 1; break; } } // 12で割ったあまりだけ進むor戻る int progress = Integer.parseInt(input[1]) % 12; int ans = hour + progress; if (ans < 0) { ans = roman.length + progress; } else if (ans > roman.length) { ans = (ans % 12); } System.out.println(roman[ans - 1]); } catch (IOException e) { e.printStackTrace(); } } }