def freq(arr)
  str, count = "", 0
  
  arr.each do |word|
    tmp = arr.count(word)
    if count < tmp
      str = word
      count = tmp
    end
  end
  
  return str
end

def max(arr)
  str = ""
  
  arr.each do |word|
    str = word if str.length < word.length
  end
  
  return str
end

arr = gets.split

puts "#{freq(arr)} #{max(arr)}"