def es()
  a = gets.split(' ')
  b = Hash.new(0)
  q = []
  for j in 0..a.length-1
    if b[a[j]] > 0
      b[a[j]] += 1
    else
      b[a[j]] = 1
    end
  end
  m = b.max { |x, y| x[1] <=> y[1] }
  print m[0]
  print ' '
  for i in 0..a.length-1
    q[i] = a[i].size
  end
  puts a[q.index(q.max)]
end

es()