#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<string> v;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  int r = 0, c = 0, e_r = 0, e_c = 0, k = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (v[i][j] == '*') {
        k++;
        e_r = max(e_r, i);
        e_c = max(e_c, j);
        if (k == 1) {
          r = i;
          c = j;
        } else {
          r = min(r, i);
          c = min(c, j);
        }
      }
    }
  }
  for (int i = r; i <= e_r; i++) {
    for (int j = c; j <= e_c; j++) cout << v[i][j];
    cout << endl;
  }
}
