a=input().split(" ")
c=[int(i) for i in a]
num=0
for i in c:
if c.count(i)>num:
max_num=i
num=c.count(i)
elif c.count(i)==num:
max_num=min(i,max_num)
print(max_num)
a=input().split(" ")
c=[int(i) for i in a]
num=0
for i in c:
if c.count(i)>num:
max_num=i
num=c.count(i)
elif c.count(i)==num:
max_num=min(i,max_num)
print(max_num)