#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  cin >> m >> n;
  char d[m][n];
  int ub = m, lb = 0, lfb = n, rb = 0;
  for (int r = 0; r < m; r++) {
    for (int c = 0; c < n; c++) {
      cin >> d[r][c];
      if (d[r][c] == '*') {
        if (ub > r) ub = r;
        if (lb < r) lb = r;
        if (rb < c) rb = c;
        if (lfb > c) lfb = c;
      }
    }
  }
  for (int r = ub; r <= lb; r++) {
    for (int c = lfb; c <= rb; c++) cout << d[r][c];
    cout << endl;
  }
  return 0;
}
