#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, n, r, S, Z, s1, s2, s3, s4, s5, s6, s7, s8, x, y, z, m, j, l, k,
      t;
  long long a[500005];
  long long b[300045];
  long long c[300001];
  long long d[100001];
  long long e[101][101];
  pair<long long, long long> aa[200001];
  pair<long long, long long> bb[200001];
  double h, w, u, v, uu, vv;
  string q1;
  string q2;
  string q3;
  string q4;
  string s;
  string q;
  string sq[50005];
  string qs[3001];
  map<string, long long> g;
  map<string, long long>::iterator it;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> sq[i];
  }
  for (i = 1; i <= n; i++) {
    x = 0;
    for (j = 0; j < m; j++) {
      if (sq[i][j] == '*') x++;
    }
    if (x != 0) {
      s1 = i;
      break;
    }
  }
  for (i = n; i > 0; i--) {
    x = 0;
    for (j = 0; j < m; j++) {
      if (sq[i][j] == '*') x++;
    }
    if (x != 0) {
      s2 = i;
      break;
    }
  }
  for (i = 0; i < m; i++) {
    x = 0;
    for (j = 1; j <= n; j++) {
      if (sq[j][i] == '*') x++;
    }
    if (x != 0) {
      s3 = i;
      break;
    }
  }
  for (i = m - 1; i >= 0; i--) {
    x = 0;
    for (j = 1; j <= n; j++) {
      if (sq[j][i] == '*') x++;
    }
    if (x != 0) {
      s4 = i;
      break;
    }
  }
  for (i = s1; i <= s2; i++) {
    for (j = s3; j <= s4; j++) {
      cout << sq[i][j];
    }
    cout << endl;
  }
}
