#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  char a[n][m];
  int r1 = n, r2 = n, c1 = m, c2 = m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] == '*') {
        if (r1 == n) {
          r1 = i;
          c1 = j;
          c2 = j;
        }
        r2 = i;
        if (j < c1) c1 = j;
        if (j > c2) c2 = j;
      }
    }
  }
  for (int i = r1; i <= r2; i++) {
    for (int j = c1; j <= c2; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}
