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

solve :: [String] -> String
solve xs
    | b && c = m : solve next
    | b = [m]
    | c = solve next
    | otherwise = []
    where
        m = head $ minimumBy (comparing head) xs
        (next, b, c) = check m xs

check :: Char -> [String] -> ([String], Bool, Bool)
check m ((x : xs) : xss)
    | m == x = (xs : ys, b, not (null xs) && c)
    | otherwise = ((x : xs) : ys, False, c)
    where
        (ys, b, c) = check m xss
check _ _ = ([], True, True)
