# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0029&lang=jp

strings = gets.split(" ")
hash = Hash.new(0)
strings.each_with_index do |e,i|
  #各ハッシュ要素には、　配列[出現数、文字の長さ]　を与える
    hash[e] =
    [
      hash[e][0] + 1,
      e.length
    ]
end

max_s = 0
longest_size = 0


hash.each do |s, (num_i, size_i)|
  # puts "#{s} #{num_i} #{size_i}"
  if num_i > max_s
    max_s = num_i
    @max_s_string = s
  end

  if size_i > longest_size
    longest_size = size_i
    @longest_size_string = s
  end
end

puts "#{@max_s_string} #{@longest_size_string}"
