#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string a[n + 1];
  for (int i = 0; i < n; i++) cin >> a[i];
  int rmin = 1000, rmax = 0, cmin = 1000, cmax = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '*' and i < rmin) rmin = i;
      if (a[i][j] == '*' and j < cmin) cmin = j;
      if (a[i][j] == '*' and i > rmax) rmax = i;
      if (a[i][j] == '*' and j > cmax) cmax = j;
    }
  }
  for (int i = rmin; i <= rmax; i++) {
    for (int j = cmin; j <= cmax; j++) cout << a[i][j];
    cout << endl;
  }
  return 0;
}
