function main(arg){
    arg = arg.split("\n")
    var _tmp  = arg[0].split(" ")
    var h = _tmp[0]
    var w = _tmp[1]
    var data = []
    var buffer_w = []
    var buffer_h = []
    arg.shift()

    var i = 0
    var j = 0
    for (i = 0;i < arg.length; i++) {
        data.push(arg[i].split(""))
    }

    for (i = 0; i < w; i++) {
        if (data[i].join("").indexOf("#") === -1) {
            buffer_w.push(i)
        }
    }

    for (i = 0; i < h; i++) {
        var text = ""
        for (j = 0; j < w;j++) {
            text += data[j][i]
        }

        if (text.indexOf("#") === -1) {
            buffer_h.push(i)
        }
    }

    for (i = 0;i<w;i++) {
        var text = ""
        for (j=0;j<h;j++) {
            if (buffer_h.indexOf(j) === -1 && buffer_w.indexOf(i) === -1) {
                text += data[i][j]
            }
        }
        if (text !== "") {
            console.log(text)
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));