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] rowSkip, colSkip;

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

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

    for (int r = 0; r < rows; r++) {
        if (r in rowSkip) continue;
        for (int c = 0; c < cols; c++) {
            if (c in colSkip) continue;
            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);
}
