fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map{it.toInt()}

    val a = Array(H) { readLine()!! }.filter { it.any{it == '#'} }
    val b = (0 until W).filter { j -> a.any {it[j] == '#'} }

    a.forEach {s -> run {
        b.forEach { print(s[it]) }
        println()
    }}
}
