#include #include #include #include using namespace std; int main() { string s1; int T; cin >> s1 >> T; int s = 0; if (s1 == "IX") s = 9; else for (int i = 0; i < s1.size(); i++) s += (s1[i] == 'I' ? 1 : (s1[i] == 'V' ? 5 : 10)); int t = (s + T + 1200) % 12; cerr << s << " " << t << endl; if (t == 9) cout << "IX"; else if (!t) cout << "XII"; else { while (t) { if (t >= 10) { cout << "X"; t -= 10; } else if (t >= 5) { cout << "V"; t -= 5; } else { cout << "I"; t--; } } } cout << endl; return 0; }