#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, a, b, c, d, fl;
  string s[50];
  cin >> n >> m;
  for (i = 0; i < n; i = i + 1) {
    cin >> s[i];
  }
  fl = 0;
  for (i = 0; i < n; i = i + 1) {
    for (j = 0; j < m; j = j + 1) {
      if (s[i][j] == '*') {
        a = i;
        fl = 1;
        break;
      }
    }
    if (fl == 1) {
      break;
    }
  }
  for (i = 0; i < n; i = i + 1) {
    for (j = 0; j < m; j = j + 1) {
      if (s[i][j] == '*') {
        c = i;
      }
    }
  }
  fl = 0;
  for (j = 0; j < m; j = j + 1) {
    for (i = 0; i < n; i = i + 1) {
      if (s[i][j] == '*') {
        b = j;
        fl = 1;
        break;
      }
    }
    if (fl == 1) {
      break;
    }
  }
  for (j = 0; j < m; j = j + 1) {
    for (i = 0; i < n; i = i + 1) {
      if (s[i][j] == '*') {
        d = j;
      }
    }
  }
  for (i = a; i <= c; i = i + 1) {
    for (j = b; j <= d; j = j + 1) {
      cout << s[i][j];
    }
    cout << endl;
  }
}
