fun main(args: Array<String>) {
  val (h, w) = readLine()!!.split(" ").map { it.toInt() }
  val a = Array(h) { readLine()!! }
  var row = BooleanArray(h) { i -> a[i].all { it == '.' } }
  var col = BooleanArray(w) { i -> a.all { it[i] == '.' } }
  for (i in 0 until h) {
    if (row[i]) continue
    println(a[i].filterIndexed { id, value -> !col[id] })
  }
}
