import Control.Monad
import Data.List
main = do
  [h,_] <- map read . words <$> getLine
  as <- replicateM h getLine
  putStr $ unlines $transpose $ filter (not . all (=='.')) (transpose (filter (not . all (=='.')) as))
