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


void main()
{
  int h, w;
  readf("%s %s\n", &h, &w);
  auto m = new char[][](h, w);
  auto f = new bool[][](h, w);
  foreach (i; 0..h) {
    m[i] = readln.chomp.to!(char[]);
    if (m[i].count!(x=>x=='.') == w) {
      f[i][] = true;
    }
  }

  foreach (i; 0..w) {
    int cnt;
    foreach (j; 0..h) {
      if (m[j][i] == '.') {
        cnt++;
      }
    }
    if (cnt == h) {
      foreach (j; 0..h) {
        f[j][i] = true;
      }
    }
  }
  foreach (i; 0..h) {
    int cnt;
    foreach (j; 0..w) {
      if (f[i][j]) continue;
      m[i][j].write;
      cnt++;
    }
    if (cnt) {
      writeln("");
    }
  }
}
