import Data.List
import Control.Monad

main :: IO ()
main = do
    n <- getLine >>= return . (read :: String -> Int)
    s <- replicateM n getLine
    putStr $ unlines $ filterForSorted $ sort s

finishing :: (a,Int,[a],Int) -> [a]
finishing (xx,m,y,n)
    | m > n = [xx]
    | m < n = y
    | m == n = xx:y

filterForSorted :: [String] -> [String]
filterForSorted = finishing . foldr useForFold ("",0,[],0) 

useForFold :: Eq a => a -> (a,Int,[a],Int) -> (a,Int,[a],Int)
useForFold x (xx,m,y,n)
    | x == xx = (x,m+1,y,n)
    | m > n = (x,1,[xx],m)
    | m < n = (x,1,y,n)
    | m == n = (x,1,(xx:y),n)