# coding: utf-8

array = gets.chomp.split(' ')

# ??????????????????????????????????????????
cnt = Hash.new(0)
array.each do |word|
  cnt[word] += 1
end
max_pres = cnt.sort_by {|k, v| v}.pop[0]

# ??????????????°????????????????????????
max_len = array.sort_by {|item| item.length}.pop

# ???????????????
puts "#{max_pres} #{max_len}"