
fun main(args:Array<String>) {
    val (h,w) = readLine()!!.split(" ").map { it.toInt() }
    var map = (1..h).map { readLine()!!.toMutableList() }.toMutableList()
    for(i in (0 until w).reversed()) {
        if(map.map { it[i] }.all { it == '.' }) {
            map.forEach { it.removeAt(i) }
        }
    }
    map.filter { it.contains('#') }.forEach { println(it.joinToString("")) }
}