x=input().split()

longestWord= ""

mostWord=0

currentCount=0

THEmostWord=""





for r in range (len(x)):

    if len(x[r])> len(longestWord):

        longestWord=x[r]



for j in range (len(x)):

    thing= x[j]

    currentCount=x.count(thing)

    if currentCount > mostWord:

        mostWord= currentCount

        THEmostWord=thing

        





print((THEmostWord, longestWord))
a=input().split()

dawa=''

d={}

for w in a:

	if len(w)>len(dawa): dawa=w

	d[a.count(w)]=w

m=max(d.keys())

akeh=d.get(m)

print('%s %s' % (akeh,dawa))
x = input().split()
longestWord = ""
mostWord = 0
currentCount = 0
THEmostWord = ""
for r in range(len(x)):
    if len(x[r]) > len(longestWord):
        longestWord = x[r]
for j in range(len(x)):
    thing = x[j]
    currentCount = x.count(thing)
    if currentCount > mostWord:
        mostWord = currentCount
        THEmostWord = thing
print((THEmostWord, longestWord))

a = input().split()
dawa = ""
d = {}
for w in a:
    if len(w) > len(dawa):
        dawa = w
    d[a.count(w)] = w
m = max(d.keys())
akeh = d.get(m)
print("%s %s" % (akeh, dawa))

-x = input().split() -longestWord = "" -mostWord = 0 -currentCount = 0 -THEmostWord = "" -for r in range(len(x)): -    if len(x[r]) > len(longestWord): -        longestWord = x[r] -for j in range(len(x)): -    thing = x[j] -    currentCount = x.count(thing) -    if currentCount > mostWord: -        mostWord = currentCount -        THEmostWord = thing -print((THEmostWord, longestWord)) +a = input().split() +dawa = "" +d = {} +for w in a: +    if len(w) > len(dawa): +        dawa = w +    d[a.count(w)] = w +m = max(d.keys()) +akeh = d.get(m) +print("%s %s" % (akeh, dawa))