module Main where

import           Control.Monad
import           Data.List

main :: IO ()
main = do
    [h, _] <- map read . words <$> getLine
    ass <- replicateM h getLine
    putStr $ solve ass

solve :: [String] -> String
solve = unlines . transpose . filter (any (== '#')) . transpose . filter (any (== '#'))