import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "l    ", long, "r");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long h, w;
    scan(h, w);
    auto mat = new string[](h);
    foreach (i; iota(h))
    {
        mat[i] = sread();
    }

    auto h_skip = new bool[](h), w_skip = new bool[](w);
    h_skip[] = true;
    w_skip[] = true;

    foreach (i; iota(h))
    {
        foreach (j; iota(w))
        {
            h_skip[i] &= (mat[i][j] == '.');
            w_skip[j] &= (mat[i][j] == '.');
        }
    }
    foreach (i; iota(h))
    {
        if (h_skip[i])
            continue;

        foreach (j; iota(w))
        {
            if (w_skip[j])
                continue;

            mat[i][j].write();
        }
        writeln();
    }
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
