import Data.List
main = interact $ unlines . map (unwords . english_sentence . words) . lines
english_sentence s = [mostfreq, mostlong]
 where
  mostfreq = (head . snd . head . reverse . sort . map (\ws -> (length ws, ws)) . group . sort) s
  mostlong = foldr1 (\s1 s2 -> if length s1 > length s2 then s1 else s2) s