#include #include int main(void){ int i; int T; char S1[4]; scanf("%s %d", S1, &T); if(strcmp(S1, "IX") == 0) T += 9; else{ for(i = 0; S1[i] != '\0'; i++){ if(S1[i] == 'I') T += 1; else if(S1[i] == 'V') T += 5; else if(S1[i] == 'X') T += 10; } } if(T >= 0) T = T % 12; else T = 12 - (-T % 12); if(T == 0) printf("XII\n"); else if(T == 9) printf("IX\n"); else{ i = 0; while(1){ if(T == 0) break; else if(T >= 10){ S1[i] = 'X'; T = T - 10; i++; } else if(T >= 5){ S1[i] = 'V'; T = T - 5; i++; } else if(T >= 1){ S1[i] = 'I'; T = T - 1; i++; } } } S1[i] = '\0'; printf("%s\n", S1); return 0; }