#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int i1 = -1, j1 = -1, i2 = -1, j2 = -1;
  vector<vector<char> > s(n);
  for (int i = 0; i < n; i++) {
    vector<char> s1(m);
    s[i] = s1;
    for (int j = 0; j < m; j++) {
      cin >> s[i][j];
      if (s[i][j] == '*' && i1 == -1) {
        i1 = i;
      }
      if (s[i][j] == '*' && (j1 == -1 || j < j1)) {
        j1 = j;
      }
      if (s[i][j] == '*' && (j2 == -1 || j > j2)) {
        j2 = j;
      }
      if (s[i][j] == '*') i2 = i;
    }
  }
  for (int i = i1; i <= i2; i++) {
    for (int j = j1; j <= j2; j++) {
      cout << s[i][j];
    }
    cout << endl;
  }
  return 0;
}
