import Control.Monad
import Data.List

del :: [String] -> [String]
del = filter (\a -> not . all (== '.') $ a)

main :: IO ()
main = do
    [h, w] <- fmap (map read . words) getLine :: IO [Int]
    a <- replicateM h getLine
    putStr . unlines . transpose . del . transpose . del $ a