#include <bits/stdc++.h>
using namespace std;
int main() {
  bool b1 = 1, b2 = 1;
  int x, y;
  cin >> x >> y;
  int arr[4] = {0};
  vector<vector<char> > v(x);
  for (int i = 0; i < x; ++i) {
    for (int j = 0; j < y; ++j) {
      char z;
      cin >> z;
      v[i].push_back(z);
    }
  }
  for (int i = 0, i2 = x - 1; i < x && i2 >= 0; ++i, i2--) {
    for (int j = 0, j2 = y - 1; j < y && j2 >= 0; ++j, j2--) {
      if (v[i][j] == '*' && b1) {
        arr[0] = i;
        b1 = 0;
      }
      if (v[i2][j2] == '*' && b2) {
        arr[2] = i2;
        b2 = 0;
      }
    }
  }
  b1 = 1, b2 = 1;
  for (int i = 0, i2 = y - 1; i < y && i2 >= 0; ++i, i2--) {
    for (int j = 0, j2 = x - 1; j < x && j2 >= 0; ++j, j2--) {
      if (v[j][i] == '*' && b1) {
        arr[1] = i;
        b1 = 0;
      }
      if (v[j2][i2] == '*' && b2) {
        arr[3] = i2;
        b2 = 0;
      }
    }
  }
  for (int i = arr[0]; i <= arr[2]; ++i) {
    for (int j = arr[1]; j <= arr[3]; ++j) {
      cout << v[i][j];
    }
    cout << endl;
  }
  return 0;
}
