def freq_max(arr)
  str1, str2, count = "", "", 0
  
  arr.each do |word|
    tmp = arr.count(word)
    str1, count = word, tmp if count < tmp
    str2 = word if str2.length < word.length
  end
  
  return [str1, str2]
end

puts freq_max(gets.split).join(" ")