import Control.Monad
import Data.List
import Data.Ord
main = readLn >>= flip replicateM getLine >>= putStrLn . solve . fmap sort

solve :: [String] -> String
solve xs
    | any null xs = []
    | b = m : solve ys
    | otherwise = solve ys
    where
        m = head $ minimumBy (comparing head) xs
        (ys, b) = foldr ff ([], True) xs
        ff x (acc, c)
            | head x == m = (tail x : acc, c)
            | otherwise = (x : acc, False)
