s=input()
dic={}
re=[]
for i in s:
if i not in dic:
dic[i]=1
else:
dic[i]+=1
min_num=min(dic.values())
for j in s:
if dic[j]!=min_num:
re.append(j)
print(''.join(re))

s=input()
dic={}
re=[]
for i in s:
if i not in dic:
dic[i]=1
else:
dic[i]+=1
min_num=min(dic.values())
for j in s:
if dic[j]!=min_num:
re.append(j)
print(''.join(re))