import qualified Data.ByteString.Char8 as BS
import qualified Data.Maybe as MA
import qualified Data.Sequence as SQ
import qualified Data.Vector as V
import qualified Data.HashMap.Strict as HM
import qualified Data.Vector.Mutable as VM
import Control.Monad
import Data.IORef

main = do
    (n, _) <- MA.fromJust . BS.readInt <$> BS.getLine
    m <- newIORef (0 :: Int)
    v <- newIORef (V.fromList (replicate n SQ.empty))
    hm <- newIORef (HM.empty :: HM.HashMap BS.ByteString Int)
    forM [0..n-1] $ \_ -> do
        s <- BS.getLine
        modifyIORef' hm (\hm' -> HM.alter (\v -> case v of
                                                   Just v -> Just $ v + 1
                                                   Nothing -> Just 0
                                          ) s hm')
        now <- (HM.! s) <$> readIORef hm
        modifyIORef' v (\v' -> V.modify (\v'' -> VM.modify v'' (\sq -> sq SQ.|> s) now ) v')
        modifyIORef' m (\m' -> if now > m' then now else m')
    m' <- readIORef m
    answer <- SQ.sort . (V.! m') <$> readIORef v
    forM_ answer $ \l -> 
        BS.putStrLn l