import sys rom_dic = {"I": 1, "V": 5, "X": 10, "L": 50, "C": 100, "D": 500, "M": 1000} n = input() rom_nums = input().split() def r2n(s): rs = [rom_dic[x] for x in s] s = rs[-1] for a, b in zip(rs[:-1], rs[1:]): s += -a if a < b else a return s def n2r(n): d2r = {0: "", 1: "I", 2: "II", 3: "III", 4: "IV", 9:"IX"} rs = [] a = ["IVX", "XLC", "CDM", "M "] while n: n, d = divmod(n, 10) if d < 5: r = d2r[d] elif 5 <= d < 9: r = "V" + d2r[d - 5] else: r = d2r[9] rs.append(r.translate(str.maketrans("IVX", a.pop(0)))) return "".join(reversed(rs)) def main(argv): s = sum([r2n(x) for x in rom_nums]) if s > 3999: print("ERROR") sys.exit(0) print(n2r(s)) if __name__ == "__main__": main(sys.argv)