import strutils, sequtils proc `*`(x: char, y: int): auto = repeat(x, y) proc `%`(x, y: int): auto = x mod y proc trfm(i: int): string = const tmax = 12 let i = (i % tmax + tmax) % tmax case i: of 0: result = "XII" of 1 .. 4: result = 'I' * i of 5 .. 8: result = 'V' & 'I' * (i % 5) of 9: result = "IX" else: result = 'X' & 'I' * (i % 10) let S1_T = readLine(stdin).split for i in 0 ..< 12: if i.trfm == S1_T[0]: echo (i + S1_T[1].parseInt).trfm