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];
    long w = hw[1];
    char[][] table;
    foreach (i; 0 .. h)
        table ~= readln.chomp.to!(char[]);

    bool[size_t] rows;
    bool[size_t] cols;

    foreach (i, r; table)
        if (r.all!(c => c == r[0]))
        {
            rows[i] = true;
        }

    foreach (i; 0 .. w)
    {
        bool flag = true;
        foreach (j; 0 .. h)
            flag = flag && table[j][i] == table[0][i];
        if (flag)
        {
            cols[i] = true;
        }
    }

    foreach (r; 0 .. h)
    {
        foreach (c; 0 .. w)
            if (!(r in rows || c in cols))
            {
                write(table[r][c]);
            }
        if (!(r in rows))
        {
            writeln;
        }
    }
}
