mystr = str(input())[::-1] # 倒序输入的数字
L=[]
for x in mystr:
if x not in L: #C++用vector理解
L.append(x)
else:
continue
print(''.join(L))
mystr = str(input())[::-1] # 倒序输入的数字
L=[]
for x in mystr:
if x not in L: #C++用vector理解
L.append(x)
else:
continue
print(''.join(L))