import Data.List
f :: [String]->[String]
f []=[]
f (x:xs)=if elem '#' x then x:f xs else f xs

main = do 
       n<-getLine
       x<-getContents
       mapM putStrLn $ transpose $ f $ transpose $ f $ lines x