import qualified Data.ByteString.Char8 as B

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

solve :: [B.ByteString] -> B.ByteString
solve = B.unlines
    . B.transpose . filter (B.elem '#')
    . B.transpose . filter (B.elem '#')