import scala.io.StdIn

object Main extends App {
  val Array(h,w) = StdIn.readLine.split(" ").map(_.toInt)

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