while n=gets
  words=n.chomp.split(" ")
end
count_max=0
count_word=0
max=0
word=0
m=words.length
m.times{|i|
  if words[i].length>max
    max=words[i].length 
    word=words[i]
  end
}
count = Hash.new(0)
words.each do |elem|
  count[elem] += 1
  if count[elem]>count_max
    count_max=count[elem]
  end
end


puts print(count.key(count_max),"\s",word)
