#main
line = gets
a = line.split(" ")
h = Hash.new
h.default = 0
a.each do |i|
  h[i] += 1
end
g = h.to_a.sort{|a, b| b[1] <=> a[1]}
f = g.sort{|a, b| b[0].length <=> a[0].length}
puts "#{g[0][0]} #{f[0][0]}"