import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }


void main() {
    string[] a;
    int n, m; readf("%d %d\n",&n, &m);
    foreach (i; 0..n) {
        string s = readln.chomp;
        if (s.count('.') != m)
            a ~= s;
    }
    string[] b;
    foreach (x; 0..m) {
        bool f = true;
        string t;
        foreach(y; 0..a.length) {
            f &= a[y][x] == '.';
            t ~= a[y][x];
        }
        if (f) continue;
        b ~= t;
    }
    
    foreach (x; 0..b[0].length) foreach (y; 0..b.length) {
        write(b[y][x]);
        if (y == b.length - 1) writeln();
    }
}
