#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, mni = 1000, mnj = 1000, mxi = 0, mxj = 0;
  cin >> n >> m;
  char arr[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
      if (arr[i][j] == '*') {
        if (i < mni) {
          mni = i;
        }
        if (j < mnj) mnj = j;
        if (i > mxi) mxi = i;
        if (j > mxj) mxj = j;
      }
    }
  }
  for (int i = mni; i <= mxi; i++) {
    for (int j = mnj; j <= mxj; j++) {
      cout << arr[i][j];
    }
    cout << endl;
  }
  return 0;
}
