import Control.Monad
import Data.Maybe
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as BS

topWords :: [BS.ByteString] -> [BS.ByteString]
topWords = reverse . takeTops . sortBySnd . makePairs . sort
   where
      makePairs :: [BS.ByteString] -> [(BS.ByteString,Int)]
      makePairs = countPairs 1
      sortBySnd :: [(BS.ByteString,Int)] -> [(BS.ByteString,Int)]
      sortBySnd list = reverse $ sortBy (comparing snd) list
      takeTops :: [(BS.ByteString,Int)] -> [BS.ByteString]
      takeTops [x] = [fst x]
      takeTops (x:y:s)
         |snd x == snd y = [fst x] ++ (takeTops (y:s))
         |otherwise      = [fst x]
      countPairs :: Int -> [BS.ByteString] -> [(BS.ByteString,Int)]
      countPairs n [a] = [(a,n)]
      countPairs n (x:y:s)
         | x==y     = countPairs (n+1) (y:s)
         |otherwise = [(x,n)] ++ (countPairs 1 (y:s))

main = do
   n <- fst . fromJust . BS.readInteger <$> BS.getLine
   ss <- replicateM (fromIntegral n) BS.getLine
   mapM_ BS.putStrLn $ topWords ss