def f(A):

    x = list(A.values())

    c = x.index(max(x))

    return list(A.keys())[c]



s = input().lower().split()

A={}

B={}

for w in s:

    if w in A: A[w] += 1

    else:

        A[w] = 1

        B[w] = len(w)

w1 = f(A)

w2 = f(B)

print(w1, w2)
s = input().split()

c1 = 0

c2 = 0

for w in set(s):

    c=s.count(w)

    if c>c1: c1,w1 = c,w

    c=len(w)

    if c>c2: c2,w2 = c,w

print(w1, w2)
def f(A):
    x = list(A.values())
    c = x.index(max(x))
    return list(A.keys())[c]


s = input().lower().split()
A = {}
B = {}
for w in s:
    if w in A:
        A[w] += 1
    else:
        A[w] = 1
        B[w] = len(w)
w1 = f(A)
w2 = f(B)
print(w1, w2)

s = input().split()
c1 = 0
c2 = 0
for w in set(s):
    c = s.count(w)
    if c > c1:
        c1, w1 = c, w
    c = len(w)
    if c > c2:
        c2, w2 = c, w
print(w1, w2)

-def f(A): -    x = list(A.values()) -    c = x.index(max(x)) -    return list(A.keys())[c] - - -s = input().lower().split() -A = {} -B = {} -for w in s: -    if w in A: -        A[w] += 1 -    else: -        A[w] = 1 -        B[w] = len(w) -w1 = f(A) -w2 = f(B) +s = input().split() +c1 = 0 +c2 = 0 +for w in set(s): +    c = s.count(w) +    if c > c1: +        c1, w1 = c, w +    c = len(w) +    if c > c2: +        c2, w2 = c, w