# coding: utf-8 import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): return {key: value for key, value in ILI()} roman_table = [ ("M", 1000), ("CM", 900), ("D", 500), ("CD", 400), ("C", 100), ("XC", 90), ("L", 50), ("XL", 40), ("X", 10), ("IX", 9), ("IV", 4), ("I", 1), ] def roman_to_int(str): ret_num = 0 for c, n in roman_table: while str.startswith(c): str = str[len(c):] ret_num += n return ret_num def int_to_roman(num): ret_str = "" for c, n in roman_table: ret_str += c * (num // n) num %= n return ret_str def read(): N = II() R = list(map(str, input().split())) return (N, R) def solve(N, R): num_sum = sum(map(roman_to_int, R)) if num_sum >= 4000: return "ERROR" else: return int_to_roman(num_sum) def main(): params = read() print(solve(*params)) if __name__ == "__main__": main()