module Main where

import Control.Applicative
import Control.Monad
import Data.List (transpose)

compress :: [String] -> [String]
compress ass = filter (not . all (== '.')) ass

main :: IO ()
main = do
    [h, w] <- fmap read . words <$> getLine :: IO [Int]
    ass <- replicateM h getLine
    let ans = transpose . compress . transpose $ compress ass
    putStrLn $ unlines ans