import Control.Applicative
import Data.List

main = interact $ (unwords . ((\f g x -> [f x, g x, "\n"]) (fst . foldl1 (\x y -> if snd x > snd y then x else y) . fmap (\x -> (head x, length x)) . group . sort) (fst . foldl1 (\x y -> if snd x > snd y then x else y) . fmap (\x -> (x, length x)) . nub . sort))) . words