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

white :: [Char]
white = repeat '.'

solver :: [String] -> Int ->  [String]
solver xs c =
    let row = take c white
        ys  = filter (\x -> x /= row) xs
        len = length ys
        col = take len white
        zs  = filter (\y -> y /= col) $ transpose ys
        in transpose zs

main :: IO ()
main = do
    [r, c] <- (map read) . words <$> getLine
    table  <- replicateM r getLine
    mapM_ putStrLn $ solver table c
