fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map(String::toInt)
    var HW = Array(H) { readLine()!!.toCharArray() }.toList()
    HW = HW.filterNot { it.all { it == '.' } }
    val remove = mutableListOf<Int>()
    for (i in 0 until W) {
        var all = true
        for (j in HW.indices) {
            val cell = HW[j][i]
            if (cell == '#') {
                all =false
            }
        }
        if(all){
            remove.add(i)
        }
    }

    for (i in 0 until HW.size){
        for(j in 0 until HW[0].size){
            if(remove.contains(j)){
                continue
            }
            print(HW[i][j])
        }
        println()
    }

}