import Control.Monad
import Data.List

reduceRow :: [[Bool]] -> [[Bool]]
reduceRow = filter or

map2 :: (a -> b) -> [[a]] -> [[b]]
map2 f = map (map f)

main = do
    [y, x] <- map read . words <$> getLine
    map <- replicateM y getLine
    let ans = map2 (\b -> if b then '#' else '.') $ transpose $ reduceRow $ transpose $ reduceRow $ map2 (== '#') map
    forM_ ans putStrLn
