fun main(args: Array<String>) {
  val (H, W) = readInts()
  val a = (1..H).map { readString().toList() }
  val cntH = Array(H) { 0 }
  val cntW = Array(W) { 0 }
  for (i in 0 until H) {
    for (j in 0 until W) {
      if (a[i][j] == '#') {
        cntH[i]++
        cntW[j]++
      }
    }
  }
  for (i in 0 until H) {
    if (cntH[i] == 0) continue
    for (j in 0 until W) {
      if (cntW[j] > 0) print(a[i][j])
    }
    println()
  }
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }
