#include <bits/stdc++.h>
using namespace std;
string s[55];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int ix = 1e9, iy = 1e9, ax = 0, ay = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < m; j++) {
      if (s[i][j] == '*')
        ix = min(ix, i), iy = min(iy, j), ax = max(ax, i), ay = max(ay, j);
    }
  }
  for (int i = ix; i <= ax; i++) {
    for (int j = iy; j <= ay; j++) {
      cout << s[i][j];
    }
    cout << endl;
  }
}
