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

void main() {
    auto tmp = readln.split.to!(int[]);
    auto H = tmp[0], W = tmp[1];
    string[] A;
    foreach (i; 0..H) {
        auto as = readln.chomp;
        if (as.all!(a => a == '.')) continue;
        A ~= as;
    }
    bool[] flags = new bool[W];
    foreach (i; 0..W) {
        flags[i] = A.all!(as => as[i] == '.');
    }
    foreach (i; 0..A.length) {
        foreach (j; 0..W) {
            if (flags[j]) continue;
            write(A[i][j]);
        }
        writeln;
    }
}

