import Control.Applicative
import Control.Monad

merge :: [String] -> [String] -> [String]
merge xs [] = xs
merge [] ys = ys
merge (x:xs) (y:ys)
    | x < y     = x : merge xs (y:ys)
    | otherwise = y : merge (x:xs) ys

msort :: [String] -> [String]
msort [x] = [x]
msort x = merge (msort (take h x)) (msort (drop h x))
    where
        h = length x `div` 2

main = do
  [n, l] <- map read . words <$> getLine
  names <- replicateM n getLine
  putStrLn.concat.msort $ names