M = [
    ('I', 1),
    ('V', 5),
    ('X', 10),
    ('L', 50),
    ('C', 100),
    ('D', 500),
    ('M', 1000),
    ('IV', 4),
    ('IX', 9),
    ('XL', 40),
    ('XC', 90),
    ('CD', 400),
    ('CM', 900),
]

M = M[::-1]

R = [
    ('M', 1000),
    ('CM', 900),
    ('D', 500),
    ('CD', 400),
    ('C', 100),
    ('XC', 90),
    ('L', 50),
    ('XL', 40),
    ('X', 10),
    ('IX', 9),
    ('V', 5),
    ('IV', 4),
    ('I', 1),
]


def rev(val):
    ret = []
    for s, v in R:
        while val >= v:
            val -= v
            ret.append(s)
    return ''.join(ret)


def parse(r):
    ret = 0
    for s, v in M:
        while True:
            idx = r.find(s)
            if idx == -1:
                break
            r = r[:idx] + r[idx + len(s):]
            ret += v
    return ret


def main():
    n = int(input())
    R = list(input().split())

    ans = 0
    for r in R:
        ans += parse(r)

    if ans > 3999:
        print('ERROR')
    else:
        print(rev(ans))


main()