fun main(args: Array<String>) {
    val mod = 1000000007
    val (H,W) = readIntList()
    val list = mutableListOf<String>()
    for (h in 0 until H) {
        val line = readString()
        if (line.any { it == '#' }) list.add(line)
    }
    if (list.size == 0) {
        println()
        return
    }
    val set = mutableSetOf<Int>()

    loop@for (i in 0 until list.first().length) {
        for (s in list) {
            if (s[i] == '#') continue@loop
        }
        set.add(i)
    }

    for (l in list) {
        var ans = ""
        for ((i,c) in l.withIndex())
            if (i !in set) ans+=c

        println(ans)
    }
}

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