# AOJ 0029 English Sentence

# Python3 2018.6.12 bal4u



import collections

from operator import itemgetter



a = list(input().split())

maxlen = 0

for i in a:

	if len(i) > maxlen:

		maxlen = len(i)

		ans_max_len = i



dict = collections.Counter(a)

print((max(dict.most_common(), key=itemgetter(1))[0], ans_max_len))

# AOJ 0029 English Sentence

# Python3 2018.6.12 bal4u



a = list(input().split())

print((max(a, key=a.count), max(a, key=len)))

# AOJ 0029 English Sentence
# Python3 2018.6.12 bal4u
import collections
from operator import itemgetter

a = list(input().split())
maxlen = 0
for i in a:
    if len(i) > maxlen:
        maxlen = len(i)
        ans_max_len = i
dict = collections.Counter(a)
print((max(dict.most_common(), key=itemgetter(1))[0], ans_max_len))

# AOJ 0029 English Sentence
# Python3 2018.6.12 bal4u
a = list(input().split())
print((max(a, key=a.count), max(a, key=len)))

-import collections -from operator import itemgetter - -maxlen = 0 -for i in a: -    if len(i) > maxlen: -        maxlen = len(i) -        ans_max_len = i -dict = collections.Counter(a) -print((max(dict.most_common(), key=itemgetter(1))[0], ans_max_len)) +print((max(a, key=a.count), max(a, key=len)))