words = gets.split

hash = {}
max = 0
max_word = ""
words.each{|w|
  if w.size > max
    max = w.size
    max_word = w
  end
  hash[w] = 0 unless hash[w]
  hash[w] += 1
}

ans = hash.max {|x, y| x[1] <=> y[1]}

puts "#{ans[0]} #{max_word}"