s=gets.chomp.split(/ /)
n=s.length
hash=Hash.new(0)
max=s[0]
max_len=s[0]
for i in 0..n-1
  hash[s[i]]+=1
  if(hash[s[i]]>hash[max])
    max=s[i]
  end
  if s[i].length>max_len.length
    max_len=s[i]
  end
end

print max," ",max_len,"\n"