function main() {
    // const [ head, ...tail ] = input;
    const head = input[0];
    const tail = input.slice(1);

    // const [h, w] = head.split(' ').map(a => parseInt(a, 10));
    const parsedHead = head.split(' ').map(a => parseInt(a, 10));
    const h = parsedHead[0];
    const w = parsedHead.slice(1);
    const a_mat = tail.map(r => r.split(''));

    // 消す
    const h_a = new Array(h).fill(true);
    const w_a = new Array(w).fill(true);

    for (var i = 0; i < h; i++) {
        for (var j = 0; j < w; j++) {
            const cell = a_mat[i][j];

            const isSpace = cell === '.';

            h_a[i] = h_a[i] && isSpace;
            w_a[j] = w_a[j] && isSpace;
        }
    }

    var output = '';
    for (var i = 0; i < h; i++) {
        if (h_a[i]) continue;

        for (var j = 0; j < w; j++) {
            if (w_a[j]) continue;

            output += a_mat[i][j];
        }
        output += '\n';
    }

    console.log(output);
}

var input = [];

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    input += chunk;
});
process.stdin.on('end', function() {
    input = input.split('\n');
    main();
});