fun main(args: Array<String>) {
    val (h, w) = readIntList()
    val a = mutableListOf<CharArray>()
    for (i in 0 until h) {
        val row = readString()
        if (row != (1..w).joinToString(separator = "") { "." }) {
            a.add(row.toCharArray())
        }
    }

    val col = MutableList(w) { false }
    for (j in 0 until w) {
        for (i in a.indices) {
            if (a[i][j] == '#') {
                col[j] = true
            }
        }
    }

    for (i in a.indices) {
        for (j in 0 until w) {
            if (col[j]) {
                print(a[i][j])
            }
        }
        println()
    }

}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)