import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long h, w;
    scan(h, w);
    auto a = new string[](h);
    foreach (i; 0 .. h)
    {
        a[i] = sread();
    }
    // writeln(a);

    bool[] row = new bool[](h);
    bool[] col = new bool[](w);
    foreach (y; 0 .. h)
    {
        // writeln(a[y]);
        foreach (x; 0 .. w)
        {
            if (a[y][x] == '.')
            {
                continue;
            }
            else
            {
                row[y] = true;
                break;
            }
        }
    }

    // writeln(row);
    foreach (x; 0 .. w)
    {
        foreach (y; 0 .. h)
        {
            if (a[y][x] == '.')
            {
                continue;
            }
            else
            {
                col[x] = true;
                break;
            }
        }
    }
    // writeln(col);
    foreach (y; 0 .. h)
    {
        foreach (x; 0 .. w)
        {
            if (row[y] && col[x])
            {
                write(a[y][x]);
            }
        }
        if (row[y])
        {
            writeln();
        }
    }

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}
