function main(input) {
    let tmp = input.split("\n");
    let num = tmp[0].split(" ").map(e=>~~e);
    let arr = tmp.slice(1, num[1]+1);
    for(let i = 0;i < arr.length-1;i++) arr[i] = arr[i].slice(0, -1);
    for(let index in arr){
        if(arr[index].split("").every(a=>a==".")) arr.splice(index, 1);
    }
    let newArr = arr.map(e=>e.split(""));
    const transpose = a => a[0].map((_, c) => a.map(r => r[c]));
    let hoge = transpose(newArr);
    for(let index in hoge){
        if(hoge[index].every(a=>a==".")) hoge.splice(index, 1);
    }
    let fuga = transpose(hoge);
    console.log(fuga.join("\n").replace(/,/g, ''));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));