# -*- coding: utf-8 -*- def ator(i): s = "" t4 = i // 1000 t35 = (i % 1000) // 500 t3 = (i % 500) // 100 t25 = (i % 100) // 50 t2 = (i % 50) // 10 t15 = i % 10 // 5 t1 = i % 5 s += "M" * t4 if t35 == 1 and t3 == 4: s += "CM" elif t3 == 4: s += "CD" else: s += "D" * t35 + "C" * t3 if t25 == 1 and t2 == 4: s += "XC" elif t2 == 4: s += "XL" else: s += "L" * t25 + "X" * t2 if t15 == 1 and t1 == 4: s += "IX" elif t1 == 4: s += "IV" else: s += "V" * t15 + "I" * t1 return s def rtoa(s): sum = 0 if "IV" in s: sum += 4 s = s.replace("IV", "") if "IX" in s: sum += 9 s = s.replace("IX", "") if "XL" in s: sum += 40 s = s.replace("XL", "") if "XC" in s: sum += 90 s = s.replace("XC", "") if "CD" in s: sum += 400 s = s.replace("CD", "") if "CM" in s: sum += 900 s = s.replace("CM", "") for c in s: if c == 'I' : sum += 1 elif c == 'V': sum += 5 elif c == 'X': sum += 10 elif c == 'L': sum += 50 elif c == 'C': sum += 100 elif c == 'D': sum += 500 elif c == 'M': sum += 1000 return sum def solve(input): roma = input[1].split() sum = 0 for r in roma: sum += rtoa(r) if sum < 4000: return ator(sum) else: return "ERROR" pass if __name__ == "__main__": input = [] input += [raw_input()] input += [raw_input()] print solve(input)