import Control.Monad
import Data.List

main :: IO ()
main = do
  [n, l] <- map (read :: String -> Int) .words <$> getLine
  strs <- replicateM n getLine
  putStrLn $ solve n l strs

solve :: Int -> Int -> [String] -> String
solve n l strs = concat $take l $ sort strs
