import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(string[] g) {
    auto rows = g.length;
    auto cols = g[0].length;

    // # が存在する行、列
    bool[int] mrow, mcol;

    for (int r = 0; r < rows; r++) {
        for (int c = 0; c < cols; c++) {
            if (g[r][c] == '#') {
                mrow[r] = true;
                break;
            }
        }
    }

    for (int c = 0; c < cols; c++) {
        for (int r = 0; r < rows; r++) {
            if (g[r][c] == '#') {
                mcol[c] = true;
                break;
            }
        }
    }

    for (int r = 0; r < rows; r++) {
        if (r !in mrow) continue;
        for (int c = 0; c < cols; c++) {
            if (c in mcol) write(g[r][c]);
        }
        writeln();
    }
}

void main() {
    auto hw = readints;
    int h = hw[0];

    string[] g;
    for (int i = 0; i < h; i++) {
        g ~= read!string;
    }
    calc(g);
}
