#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<string> v(n);
  char s;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  long long a = 60, b = 0, c = 60, d = 0;
  long long flag = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (v[i][j] == '*') {
        a = min(a, i);
        b = max(b, i);
        c = min(c, j);
        d = max(d, j);
      }
    }
  }
  for (long long i = a; i < b + 1; i++) {
    {
      for (long long j = c; j < d + 1; j++) cout << v[i][j];
      cout << "\n";
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
