module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import qualified Data.Map.Strict as M


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

buildMap :: [BC.ByteString] -> M.Map BC.ByteString Int
buildMap = foldl' (\map word -> M.alter alter word map) M.empty where
    alter Nothing = Just 1
    alter (Just n) = Just $ n + 1

solve :: [BC.ByteString] -> [BC.ByteString]
solve words = let
    dict = buildMap words
    nativelst = M.toAscList dict
    lst@((fk, fn):ltr) = sortOn (negate . snd) nativelst
    filteredList = filter ((== fn) . snd) lst
    in
    fst <$> filteredList


main = do
    n <- readInt
    words <- replicateM n BC.getLine
    let ansList = solve words
    forM_ ansList BC.putStrLn

