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


main = do
    [h, w] <- map read . words <$> getLine
    lines <- replicateM h getLine
    mapM_ putStrLn $ solve lines

solve :: [String] -> [String]
solve = compressCol . compressRow

compressRow :: [String] -> [String]
compressRow = filter $ any (== '#')

compressCol :: [String] -> [String]
compressCol = transpose . compressRow . transpose
