import           Data.List

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

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