inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
l = inp.shift().split(' ')
H = l.shift() * 1
W = l.shift() * 1
a = []
for (i=0; i<H; i++) {
    b = inp[i].split('')
    if (b.indexOf('#') >= 0) {
        a.push(b)
    }
}
for (i=a[0].length-1; i>=0; i--) {
    b = 0
    for (j=a.length-1; j>=0; j--) {
        if (a[j][i] == '#') {
            b = 1
            break;
        }
    }
    if (!b) {
        for (k=a.length-1; k>=0; k--) {
            a[k].splice(i, 1)
        }
    }
}

console.log(a.map(x => x.join('')).join("\n"))