Write a program that reads a text and prints two words: the most frequently occurring word in the text and the word with the maximum number of letters. The text contains only alphabetical characters and spaces, with words separated by spaces. The input text will have a maximum of 1000 letters, and each word will have a maximum of 32 letters. The output should be the two words separated by a space. For example, given the input "Thank you for your mail and your lectures," the output should be "your lectures."

# Buggy version:
# -*- coding: utf-8 -*-
from collections import defaultdict

d = defaultdict(int)
_input = input()
sentence = [e for e in _input.split()]
l = []

for word in sentence:
    d[word] += 1

times = sorted(d.items(), key=lambda item: item[1], reverse=True)
lengths = sorted(d.items(), key=lambda item: len(item[0]), reverse=True)

print(times[0][1], end=' ')
print(lengths[0][0])

# Fixed version:
# -*- coding: utf-8 -*-
from collections import defaultdict

d = defaultdict(int)
_input = input()

for word in _input.split():
    d[word] += 1

times = sorted(d.items(), key=lambda item: item[1], reverse=True)
lengths = sorted(d.items(), key=lambda item: len(item[0]), reverse=True)

print(times[0][0], end=' ')
print(lengths[0][0])

# Buggy version:
targ = input().split(' ')
mostfre = {}
ansfre = ""
longest = [0,""]
for t in targ:
    if len(t) > longest[0]:
        longest[0],longest[1] = len(t),t
    mostfre[t] = mostfre.get(t,0) + 1
temp = 0
print(mostfre)
for k,v in mostfre.items():
    if v > temp:
        temp = v
        ansfre = k
print(ansfre + ' ' + longest[1])

# Fixed version:
targ = input().split(' ')
mostfre = {}
ansfre = ""
longest = [0,""]
for t in targ:
    if len(t) > longest[0]:
        longest[0],longest[1] = len(t),t
    mostfre[t] = mostfre.get(t,0) + 1
temp = 0
for k,v in mostfre.items():
    if v > temp:
        temp = v
        ansfre = k
print(ansfre + ' ' + longest[1])

# Buggy version:
import sys
from collections import Counter

if __name__ == '__main__':
    # ??????????????\???
    # line = 'Thank you for your mail and your lectures'
    data = []
    for line in sys.stdin:
        data = line.strip().lower().split(' ')

    print(data)

    # ??????????¢??????????
    c = Counter(data)  # ????????????????¢????
    most_frequent_word = c.most_common(1)[0][0]
    # ???????????????????????¢???
    max_length_word = ''
    for w, freq in c.most_common():
        if len(w) > len(max_length_word):
            max_length_word = w

    # ???????????¨???
    print('{0} {1}'.format(most_frequent_word, max_length_word))

# Fixed version:
import sys
from collections import Counter

if __name__ == '__main__':
    # ??????????????\???
    # line = 'Thank you for your mail and your lectures'
    data = []
    for line in sys.stdin:
        data = line.strip().strip('.').lower().split(' ')

    # print(data)

    # ??????????¢??????????
    c = Counter(data)  # ????????????????¢????
    most_frequent_word = c.most_common(1)[0][0]
    # ???????????????????????¢???
    max_length_word = ''
    for w, freq in c.most_common():
        if len(w) > len(max_length_word):
            max_length_word = w

    # ???????????¨???
    print('{0} {1}'.format(most_frequent_word, max_length_word))

# Buggy version:
s = list(input().split())
maxLen = 0
maxNum = 0
dic = {}
for word in s:
    if not (word in dic):
        dic[word] = 1
    else:
        dic[word] += 1
    if maxNum < dic[word]:
        maxNum = dic[word]
        ansNum = word
    if maxLen < len(word):
        maxLen = len(word)
        ansLen = word
print(ansNum, ansLen)
print(dic)

# Fixed version:
s = list(input().split())
maxLen = 0
maxNum = 0
dic = {}
for word in s:
    if not (word in dic):
        dic[word] = 1
    else:
        dic[word] += 1
    if maxNum < dic[word]:
        maxNum = dic[word]
        ansNum = word
    if maxLen < len(word):
        maxLen = len(word)
        ansLen = word
print(ansNum, ansLen)