import           Control.Monad
import           Data.List

main :: IO ()
main = do
    [h, _] <- fmap (map read . words) getLine :: IO [Int]
    ass    <- replicateM h $ getLine :: IO [String]
    printgrid $ transpose . del . transpose . del $ ass

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

printgrid :: [String] -> IO ()
printgrid []       = return ()
printgrid (s : ss) = do
    putStrLn s
    printgrid ss
