import scala.io.StdIn._

/**
 * ABC107B
 */
object Main extends App {

  val Seq(h, w) = readLine().split(" ").toSeq.map(_.toInt)
  val blob: Seq[String] = (0 until h).map(_ => readLine()).toIndexedSeq

  val calcNewRow = (b: String) => {
    (0 until w)
      .filter(colIndex => blob.map(_(colIndex).toString).contains("#"))
      .map(b(_))
      .mkString
  }

  val ans = blob.filter(_.contains("#"))
    .map(calcNewRow(_))

  ans.foreach(println)
}
