import sys
s=['I','IV','V','IX','X','XL','L','XC','C','CD','D','CM','M']
t=['1','4','5','9','10','40','50','90','100','400','500','900','1000']
def s_to_t(n):
num=0
for i inrange(len(n)):
for j inrange(len(s)):
if n[i:i+1]==s[j]:
num = num + int(t[j])
return num
def t_to_s(t):
rnum=[]
while t>0:
if t>=1000:
t = t - 1000
rnum.append('M')
if t>=900and t<1000:
t = t - 900
rnum.append('CM')
if t>=500and t<900:
t = t - 500
rnum.append('D')
if t>=400and t<500:
t = t - 400
rnum.append('CD')
if t>=100and t<400:
t = t - 100
rnum.append('C')
if t>=90and t<100:
t = t - 90
rnum.append('XC')
if t>=50and t<90:
t = t - 50
rnum.append('L')
if t>=40and t<50:
t = t - 40
rnum.append('XL')
if t>=10and t<40:
t = t - 10
rnum.append('X')
if t>=9and t<10:
t = t - 9
rnum.append('IX')
if t>=5and t<9:
t = t - 5
rnum.append('V')
if t>=4and t<5:
t = t - 4
rnum.append('IV')
if t>=1and t<4:
t = t - 1
rnum.append('I')
return(rnum)
for line in sys.stdin:
list01 = line.split()
iflen(list01)>1:
a = int(s_to_t(list01[0]))
b = int(s_to_t(list01[1]))
ifabs(a-b)==0:
print('ZERO')
else:
result = t_to_s(abs(a-b))
rr=''
for i inrange(len(result)):
rr = rr + result[i]
print(rr)