fun main(args: Array<String>) {
    val lines = readAllLines()
    val reduced = lines.filter { !it.matches(Regex("\\.+")) }
    val w = reduced[0].length
    val isWhiteLineArray = BooleanArray(w)
    for (i in 0 until w) {
        var isWhiteLine = true
        for (j in 0 until reduced.size) {
            val c = reduced[j][i]
            isWhiteLine = isWhiteLine && c == '.'
        }
        isWhiteLineArray[i] = isWhiteLine
    }
    for (i in 0 until reduced.size) {
        for (j in 0 until w) {
            if (!isWhiteLineArray[j]) print(reduced[i][j])
        }
        println()
    }
}

fun readAllLines(): List<String> {
    val hw = readLine()!!.split(" ")
    val h = Integer.parseInt(hw[0])
    return (0 until h).map { readLine()!! }
}
