// B - Grid Compression
// https://abc107.contest.atcoder.jp/tasks/abc107_b

import scala.io.StdIn.readLine

object Main extends App {

  val Array(h, w) = readLine.split(" ").map(_.toInt)

  var ass: Array[Array[Char]] = Array.ofDim[Char](h, w)
  for (i <- 0 until h) {
    ass(i) = readLine.toCharArray
  }

  def trim(ass: Array[Array[Char]]) = {
    ass.filter(as => as.exists(_ == '#'))
  }

  val reduce_h = trim(ass)
  val reduce_w = trim(reduce_h.transpose).transpose

  reduce_w.foreach(as => println(as.mkString))

}