import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
import std.numeric;

void main()
{
    auto hw = readln.split.to!(long[]);
    long h = hw[0];
    char[][] table;
    foreach (i; 0 .. h)
        table ~= readln.chomp.to!(char[]);

    char[][] tmp = table.filter!(r => !(r.all!(c => c == '#') || r.all!(c => c == '.'))).array;

    char[][] result = new char[][](tmp.length, 0);

    foreach (col; 0 .. hw[1])
    {
        bool flag = true;
        char c = table[0][col];
        foreach (row; table)
            flag = flag && row[col] == c;
        if (!flag)
        {
            foreach (i,row; tmp)
                result[i] ~= row[col];
        }
    }

    result.to!(string[]).join("\n").writeln;
}
