#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y);
long long int mpower(long long int x, long long int y, long long int p);
long long int modInv(long long int a, long long int m);
long long int gcdExtended(long long int a, long long int b, long long int *x,
                          long long int *y);
bool isPrime(long long int n);
long long int lvl[1000][1000];
bool A[1000][1000];
long long int modInv(long long int a, long long int m) {
  long long int x, y;
  long long int g = gcdExtended(a, m, &x, &y);
  long long int res = (x % m + m) % m;
  return res;
}
long long int gcdExtended(long long int a, long long int b, long long int *x,
                          long long int *y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long int x1, y1;
  long long int gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long int mpower(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  long long int p = sqrt(n);
  for (int i = 5; i <= p; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t, n, m, k, q, p, r, a, b, c, d, x, y, z, h, o, e, l, u;
  t = 1;
  while (t--) {
    cin >> n >> m;
    string s[n];
    for (long long int i = 0; i < n; i++) cin >> s[i];
    l = m - 1, r = 0, u = n - 1, d = 0;
    k = 0, p = 0;
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < m; j++) {
        if (s[i][j] == '*') {
          if (j < l) l = j;
          if (j > r) r = j;
          if (i < u) u = i;
          if (i > d) d = i;
        }
      }
    }
    for (long long int i = u; i <= d; i++) {
      for (long long int j = l; j <= r; j++) {
        cout << s[i][j];
      }
      cout << '\n';
    }
  }
}
