#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, maxx = 0, maxy = 0, minx = ~0u / 2, miny = ~0u / 2;
  cin >> n >> m;
  vector<string> s;
  for (int i = 0; i < n; i++) {
    string p;
    cin >> p;
    s.push_back(p);
    for (int j = 0; j < s[i].size(); ++j) {
      if (s[i][j] == '*') {
        if (i > maxy) maxy = i;
        if (j > maxx) maxx = j;
        if (i < miny) miny = i;
        if (j < minx) minx = j;
      }
    }
  }
  for (int i = miny; i < (maxy + 1); ++i) {
    for (int j = minx; j < (maxx + 1); ++j) {
      cout << s[i][j];
    }
    cout << endl;
  }
}
