import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val h = sc.nextInt()
  val w = sc.nextInt()

  val a = Array(h) { sc.next().toCharArray() }

  val hh = mutableListOf<Int>()
  for (i in 0 until h) {
    var all = true
    for (j in 0 until w) {
      if (a[i][j] == '#') {
        all = false
        break
      }
    }
    if (!all) {
      hh.add(i)
    }
  }

  val ww = mutableListOf<Int>()
  for (j in 0 until w) {
    var all = true
    for (i in 0 until h) {
      if (a[i][j] == '#') {
        all = false
        break
      }
    }
    if (!all) {
      ww.add(j)
    }
  }

  val ans = mutableListOf<String>()

  for (i in hh) {
    for (j in ww) {
      ans.add(a[i][j].toString())
    }
    ans.add("\n")

  }

  println(ans.joinToString(""))

}
