fun main(args: Array<String>) {
  val (H,W) = readLine()!!.split(" ").map{it.toInt()}
  var rows  = (1..H).map{readLine()!!.toString()}.filter{it.contains('#')}
  val height = rows.size - 1

  val colums = (0 until W).filter{x ->
    (0..height).any{y ->
      rows[y].get(x) == '#'
    }
  }

  for(h in 0 .. height){
    //出力文字列を作ってる
    val newRow = colums.map{y -> rows[h].get(y)}
    for(n in newRow) {
      print(n)
    }
    println()
  }
}