import qualified Data.ByteString.Char8 as BS
import Data.List (group, sort, sortBy)

main = do
  n <- getLine
  s <- BS.lines <$> BS.getContents
  mapM_ (\x -> putStrLn $ BS.unpack $ fst x)
        $ sort
        $ removeExceptMax
        $ map (\list -> (head list, length list))
        $ group
        $ sort s

removeExceptMax :: [(BS.ByteString, Int)] -> [(BS.ByteString, Int)]
removeExceptMax xs =
  filter (\x -> snd x == m) xs 
  where
    m = maximum $ map snd xs