import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val h = sc.nextInt()
    val w = sc.nextInt()
    val countH = Array(h) {0}
    val countV = Array(w) {0}
    val a = (0 until h).map {i->
        val line = sc.next()
        for (j in line.indices) {
            if (line[j] == '.') {
                countH[i]++
                countV[j]++
            }
        }
        line
    }
    for (i in 0 until h) {
        if (countH[i] == w) {
            continue
        }
        for (j in 0 until w) {
            if (countV[j] != h) {
                print(a[i][j])
            }
        }
        println()
    }
}