import Control.Monad
import Data.List
main = do
  [h,w] <- map read . words <$> getLine
  a <- replicateM h getLine
  mapM_ putStrLn . filter (not . all (== '.')) . transpose . filter (not . all (== '.')) $ transpose a