#include using namespace std; int main(){ string str; int t; cin >> str >> t; if(t < 0){ t = 12 - (abs(t) % 12); } int now = 0; if(str == "IX") now = 9; else{ for(int i = 0; i < str.length(); i++){ if(str[i] == 'X') now += 10; else if(str[i] == 'V') now += 5; else now++; } } int after = (now + t) % 12; if(after == 0) cout << "XII"; else if(after == 9) cout << "IX"; else{ int ten = after / 10; after -= ten * 10; int five = after / 5; after -= five * 5; int one = after; for(int i = 0; i < ten; i++) cout << "X"; for(int i = 0; i < five; i++) cout << "V"; for(int i = 0; i < one; i++) cout << "I"; } cout << endl; }