#include <bits/stdc++.h>
using namespace std;
int maxx = 0, maxy = 0, minx = 50, miny = 50, n, m;
char c[51][51];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> c[i][j];
      if (c[i][j] == '*')
        maxx = max(maxx, i), minx = min(minx, i), maxy = max(maxy, j),
        miny = min(miny, j);
    }
  for (int i = minx; i <= maxx; i++) {
    for (int j = miny; j <= maxy; j++) putchar(c[i][j]);
    puts("");
  }
  return 0;
}
