#include <bits/stdc++.h>
using namespace std;
char a[100][100];
int l, r, u, d;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) cin >> a[i][j];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == '*') {
        u = i;
        break;
      }
    }
    if (u != 0) break;
  }
  for (int i = n; i >= 1; i--) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == '*') {
        d = i;
        break;
      }
    }
    if (d != 0) break;
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[j][i] == '*') {
        l = i;
        break;
      }
    }
    if (l != 0) break;
  }
  for (int i = m; i >= 1; i--) {
    for (int j = 1; j <= n; j++) {
      if (a[j][i] == '*') {
        r = i;
        break;
      }
    }
    if (r != 0) break;
  }
  for (int i = u; i <= d; i++) {
    for (int j = l; j <= r; j++) {
      cout << a[i][j];
    }
    cout << '\n';
  }
  return 0;
}
