#include #include using namespace std; int main(){ string S; int T; cin >> S >> T; int now_time = 0; if(S == "IX"){ now_time = 9; }else{ for(int i = 0; i < S.size(); i++){ if(S[i] == 'X'){ now_time += 10; }else if(S[i] == 'V'){ now_time += 5; }else{ now_time++; } } } now_time = (now_time + T + 1199) % 12 + 1; if(now_time == 9){ cout << "IX" << endl; }else{ for(int i = 0; i < now_time / 10; i++){ cout << "X" << endl; } now_time -= now_time / 10; for(int i = 0; i < now_time / 5; i++){ cout << "V" << endl; } now_time -= now_time / 5; for(int i = 0; i < now_time; i++){ cout << "I" << endl; } } }