import Control.Monad
import Data.List

main = do
 [a,b] <- map (read :: String -> Int).words<$>getLine
 s <- replicateM a (getLine)
 putStrLn.unlines $ solve s

solve s = transpose $ sieve $ transpose (sieve s)

sieve :: [[Char]] -> [[Char]]
sieve [] = []
sieve (a:as) | elem '#' a = [a] ++ sieve as
 | otherwise = sieve as