#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, l = 0, i = 0, c = 0;
  cin >> n >> m;
  vector<string> q(n);
  while (i < n) {
    cin >> q[i];
    i++;
  }
  int a = 0, b = 0, x = n, y = m;
  i = 0;
  while (i < n) {
    while (l < m) {
      if (q[i][l] == '*') {
        c = 1;
      }
      l++;
    }
    l = 0;
    if (c == 0) {
      a++;
    } else {
      break;
    }
    i++;
  }
  i = 0;
  c = 0;
  while (i < m) {
    while (l < n) {
      if (q[l][i] == '*') {
        c = 1;
      }
      l++;
    }
    l = 0;
    if (c == 0) {
      b++;
    } else {
      break;
    }
    i++;
  }
  i = n - 1;
  l = m - 1;
  c = 0;
  while (i >= 0) {
    while (l >= 0) {
      if (q[i][l] == '*') {
        c = 1;
      }
      l--;
    }
    l = m - 1;
    if (c == 0) {
      x--;
    } else {
      break;
    }
    i--;
  }
  i = m - 1;
  l = n - 1;
  c = 0;
  while (i >= 0) {
    while (l >= 0) {
      if (q[l][i] == '*') {
        c = 1;
      }
      l--;
    }
    l = n - 1;
    if (c == 0) {
      y--;
    } else {
      break;
    }
    i--;
  }
  i = a;
  l = b;
  while (i < x) {
    while (l < y) {
      cout << q[i][l];
      l++;
    }
    cout << '\n';
    i++;
    l = b;
  }
  return 0;
}
