#include <bits/stdc++.h>
using namespace std;
char a[55][55];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int right = 0, left = 1000;
  int top = 1000, ceil = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i][j] == '*') {
        if (i < top) {
          top = i;
        }
        if (i > ceil) {
          ceil = i;
        }
        if (j > right) {
          right = j;
        }
        if (j < left) {
          left = j;
        }
      }
    }
  }
  for (int i = top; i <= ceil; ++i) {
    for (int j = left; j <= right; ++j) {
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}
