import std.stdio;
import std.conv;
import std.string;

void main() {
    ulong h, w;
    string[] a;

    readf(" %s %s\n", &h, &w);

    foreach (_; 0..h) {
         string input = readln.chomp;
         bool f = false;
         foreach (i; input) {
            if (i != '.')
                f = true;
         }
         if (f)
            a ~= input;
    }
    h = a.length;

    auto ans = new char[][](h, 0);
    foreach (i; 0..w) {
        bool f = false;
        foreach (j; 0..h) {
            if (a[j][i] != '.') {
                f = true;
                break;
            }
        }
        if (f)
            foreach (j; 0..h)
                ans[j] ~= a[j][i];
    }
    foreach (i; ans)
        i.writeln;
}
