import Control.Monad
import Data.List

main=do
    (h:w:_)<-map read.words<$>getLine::IO[Int]
    as<-filter (elem '#') <$> replicateM h getLine::IO [String]
    --
    putStr $ unlines $ transpose $ filter (elem '#') $ transpose as