#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b);
long long cross_prod(long long ax, long long ay, long long bx, long long by,
                     long long cx, long long cy);
long long sum_digit(long long A);
long long get_mask(long long x);
vector<string> V;
int N, M;
int mx = INT_MAX, my = INT_MAX, Mx, My;
int main() {
  int i, lg1, j;
  cin >> N >> M;
  V.resize(N);
  for (i = 0; i < N; ++i) {
    cin >> V[i];
  }
  for (i = 0; i < N; ++i) {
    for (j = 0; j < M; ++j) {
      if (V[i][j] == '*') {
        my = min(my, j);
        mx = min(mx, i);
        My = max(My, j);
        Mx = max(Mx, i);
      }
    }
  }
  for (i = mx; i <= Mx; ++i) {
    for (j = my; j <= My; ++j) {
      cout << V[i][j];
    }
    cout << '\n';
  }
  return 0;
}
long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); }
long long cross_prod(long long ax, long long ay, long long bx, long long by,
                     long long cx, long long cy) {
  return (bx - ax) * (cy - ay) - (by - ay) * (cx - ax);
}
long long sum_digit(long long A) {
  long long sum = 0;
  do {
    sum += A % 10;
    A /= 10;
  } while (A);
  return sum;
}
long long get_mask(long long x) {
  long long mask = 0, c;
  while (x) {
    c = x % 10;
    x /= 10;
    if (c == 4 || c == 7) {
      mask = mask * 10 + c;
    }
  }
  return mask;
}
