import Control.Monad
import Data.List

canCompressLine :: String -> Bool
canCompressLine = all (== '.')

compressLines :: [String] -> [String]
compressLines = filter (not . canCompressLine)

compressRows :: [String] -> [String]
compressRows lines = transpose $ compressLines $ transpose lines

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  lines <- replicateM h getLine
  putStrLn $ unlines $ compressRows $ compressLines lines