
fun main(args:Array<String>) {
    val (r, c) = readLine()!!.split(" ").map { it.toInt() }
    var map = (1..r).map { readLine()!! }.filter { a-> !a.all { it == '.' } }
    map = (0 until c).map {idx-> map.map { it[idx] }.joinToString("") }.filter { a -> !a.all { it == '.' } }
    map = (0 until map[0].length).map { idx -> map.map { it[idx] }.joinToString("") }
    map.forEach{ println(it)}
}