X1 = [(),(0,),(0,0),(0,0,0),(0,1),(1,),(1,0),(1,0,0),(1,0,0,0),(0,2)] X2 = [("I","V","X"),("X","L","C"),("C","D","M"),("M",)] def decode(S): i = 0 ret = 0 st = 0 N = len(S) j = N-1 while 0 <= j: s = S[j] if st == 0: if s == X2[i][0]: ret += 10 ** i j -= 1 elif s == X2[i][1]: st = 1 ret += 5 * 10 ** i j -= 1 elif s == X2[i][2]: st = 1 ret += 10 ** (i + 1) j -= 1 else: i += 1 elif st == 1: if s == X2[i][0]: ret -= 10 ** i j -= 1 st = 0 i += 1 return ret def encode(x): ret = [] if x > 3999: print("ERROR") exit() i = 0 while x > 0: a = x % 10 tmp = "" for j in X1[a]: tmp += X2[i][j] ret.append(tmp) i += 1 x //= 10 return "".join(ret[::-1]) N = int(input()) R = input().split() print(encode(sum([decode(r) for r in R])))