import scala.io.StdIn

object Main extends App {

  Iterator.continually(StdIn.readLine)
    .drop(1)
    .takeWhile(_ != null)
    .filter(_.contains('#'))
    .map(_.toCharArray)
    .toArray
    .transpose
    .filter(_.contains('#'))
    .transpose
    .foreach(ch => println(ch.mkString))

}