#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, i, ii, iii;
  string x[100];
  int start[2];
  int end[2] = {0};
  start[0] = -1;
  start[1] = -1;
  cin >> a >> b;
  for (i = 0; i < a; i++) {
    cin >> x[i];
  }
  for (i = 0; i < a; i++) {
    for (ii = 0; ii < b; ii++) {
      if (x[i][ii] == '*') {
        if (start[0] == -1) {
          start[0] = i;
          start[1] = ii;
        }
        if (ii < start[1]) {
          start[1] = ii;
        }
        end[0] = i;
        if (ii > end[1]) end[1] = ii;
      }
    }
  }
  for (i = start[0]; i <= end[0]; i++) {
    for (ii = start[1]; ii <= end[1]; ii++) {
      cout << x[i][ii];
    }
    cout << endl;
  }
  return 0;
}
