import Data.List

hoge1 :: [String] -> String
hoge1 xs = snd $ head $ reverse $ sort $ map hoge' $ group $ sort xs
    where
        hoge' (x:xs) = (length xs + 1 , x)

hoge2 :: [String] -> String
hoge2 = foldr foo ""
    where
        foo x y = if length y < length x then x else y

main :: IO ()
main  = getLine
    >>= return . words
    >>= return . (\ ss -> [hoge1 ss , " " , hoge2 ss])
    >>= mapM_ putStr
    >> putStrLn ""