-- Your code here!
-- Your code here!

import Data.List.Split
import Data.List

-- Your code here!
main :: IO()
main = do
  ls <- getLines
  mapM_ putStrLn $ getMosts ls
  
getMosts :: [String] -> [String]
getMosts l = map (\(a1,a2) -> a1) $ getMosts' $ quickSort $ counts l
  where
    getMosts' :: [(String,Int)] -> [(String,Int)]
    getMosts' [] = []
    getMosts' (a@(a1,an):as) = a:filter (\(b1,bn) -> bn == an) as
    
quickSort :: [(String,Int)] -> [(String,Int)]
quickSort [] = []
quickSort (c:as) = quickSort smaller ++ c : quickSort bigger
  where
    smaller = [a | a <- as, myCompare a c /= LT]
    bigger  = [a | a <- as, myCompare a c == LT]

myCompare :: (String,Int) -> (String,Int) -> Ordering
myCompare (a,an) (b,bn) = compare an bn


counts :: [String] -> [(String,Int)]
counts l = map count' es
  where
    es = nub l
    count' e = (e, count e l)

count e l = length $ filter (e==) l

getLines =  do
  s <- getContents
  return $ lines s
