fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toInt)
    val a = Array(h) { readLine()!! }.filterNot { it.all { it == '.' }}
    val b = (0 until w).filterNot { x -> a.all { it[x] == '.' }}
    a.forEach { row ->
        b.forEach { print(row[it]) }
        println()
    }
}
