#include #include #include #include #include #define all(x) x.begin(),x.end() #define pb push_back #define ll long long #define P pair #define LP pair using namespace std; int main() { int t,cnt,ans; string s,x; cin >>s>> t; map a; map b; a["I"] = 1; a["II"] = 2; a["III"] = 3; a["IIII"] =4; a["V"] = 5; a["VI"] = 6; a["VII"] = 7; a["VIII"] =8; a["IX"] = 9; a["X"] = 10; a["XI"] = 11; a["XII"] = 12; b[1]= "I"; b[2]="II"; b[3]="III"; b[4]="IIII"; b[5]= "V"; b[6]= "VI"; b[7]= "VII"; b[8]= "VIII"; b[9]= "IX"; b[10]= "X"; b[11]= "XI"; b[0]= "XII"; cnt = a[s]; if (t >= 0) { ans = (cnt + t % 12) % 12; cout << b[ans] << endl; } else { ans = abs(cnt - abs(t) % 12) % 12; if (cnt - abs(t) % 12 >= 0) cout << b[ans] << endl; else cout << b[12 - ans] << endl; } return 0; }