import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  [h, w] <- f
  solve <$> replicateM h getLine >>= mapM_ putStrLn
  where
    f = map read <$> words <$> getLine

solve :: [String] -> [String]
solve xs = transpose . filter (not . all (=='.')) . transpose . filter (not . all (=='.')) $ xs
