import Control.Monad
import Data.List

main=do
    n<-readLn
    putStrLn.f ['a'..'z'] =<< replicateM n (sort <$> getLine)

f [] = const []
f (a:ar) = liftM2 (++) (flip replicate a.minimum.map length.fst) (f ar.snd).unzip.map (span(==a))