#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  char flag[h][w];
  int u = h - 1, d = 0, r = 0, l = w - 1;
  for (int a = 0; a < h; a++) {
    for (int b = 0; b < w; b++) {
      cin >> flag[a][b];
      if (flag[a][b] == '*') {
        u = min(u, a);
        d = max(d, a);
        l = min(l, b);
        r = max(r, b);
      }
    }
  }
  for (int a = u; a <= d; a++) {
    for (int b = l; b <= r; b++) {
      cout << flag[a][b];
    }
    cout << endl;
  }
}
