import scala.collection.mutable.ListBuffer

object Main extends App {
  import scala.io.StdIn.readLine

  val hw = readLine().split(" ").map(_.toInt)
  val h = hw(0)
  val w = hw(1)

  var list: ListBuffer[String] = new ListBuffer[String]
  for (i <- 1 to h) {
    val line = readLine()
    line.foreach(x => {
      if (!x.equals('.'charValue())) list += line
    })
  }

  var blist: ListBuffer[Boolean] = new ListBuffer[Boolean]
  for (j <- 0 to w - 1) {
    var flag = false
    list.foreach(x => {
      if (!x(j).equals('.')) flag = true
    })
    blist += flag
  }

  for (i <- 0 to list.size - 1) {
    for (j <- 0 to w - 1) {
      if (blist(j)) print(list(i)(j))
    }
    if (i != list.size - 1) println()
  }
}