void main() {
    int[] tmp = readln.split.to!(int[]);
    int h = tmp[0], w = tmp[1];
    string[] a;
    foreach (i; 0 .. h) {
        string row = readln.chomp;
        if (row.any!(c => c == '#')) a ~= row;
    }
    h = a.length.to!int;
    int j;
    while (j < w) {
        int cnt;
        foreach (i; 0 .. h) {
            if (a[i][j] == '.') ++cnt;
        }
        if (cnt == h) {
            foreach (i; 0 .. h) {
                a[i] = a[i][0..j] ~ a[i][j+1..$];
            }
            --w;
        } else {
            ++j;
        }
    }
    foreach (x; a) {
        x.writeln;
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;