D={"I" : 1,"V" : 5,"X": 10,"L" : 50,"C" : 100,"D" : 500,"M" : 1000}

N=int(input())
A=input().split()

ANS=0

for a in A:
    ind=0

    while ind<len(a):
        if ind+1<len(a) and D[a[ind]]<D[a[ind+1]]:
            ANS+=D[a[ind+1]]-D[a[ind]]
            ind+=2
        else:
            ANS+=D[a[ind]]
            ind+=1

if ANS>=4000:
    print("ERROR")
    exit()

LS=""

while ANS:
    if ANS>=1000:
        LS+="M"
        ANS-=1000
        
    elif ANS>=900:
        LS+="CM"
        ANS-=900
        
    elif ANS>=500:
        LS+="D"
        ANS-=500
        
    elif ANS>=400:
        LS+="CD"
        ANS-=400
        
    elif ANS>=100:
        LS+="C"
        ANS-=100

    elif ANS>=90:
        LS+="XC"
        ANS-=90
        
    elif ANS>=50:
        LS+="L"
        ANS-=50
        
    elif ANS>=40:
        LS+="XL"
        ANS-=40
        
    elif ANS>=10:
        LS+="X"
        ANS-=10
 
    elif ANS>=9:
        LS+="IX"
        ANS-=9
        
    elif ANS>=5:
        LS+="V"
        ANS-=5
        
    elif ANS>=4:
        LS+="IV"
        ANS-=4
        
    elif ANS>=1:
        LS+="I"
        ANS-=1

print(LS)