import Data.List

main = do
  _ <- getLine
  ss <- return . (map sort) . lines =<< getContents

  putStrLn $ foldl1 f ss

  where
    f [] _ = []
    f _ [] = []
    f (x:xs) y =
      if i == Nothing then
        f xs y
      else
        let Just j = i
        in (y!!j) : (f xs (drop (j+1) y))
      where
        i = elemIndex x y
