#include <bits/stdc++.h>
using namespace std;
int main() {
  int rw, cl;
  cin >> rw >> cl;
  string *arr = new string[rw];
  for (int i = 0; i < rw; i++) {
    cin >> arr[i];
  }
  int mnR = 2000, mnC = 2000;
  int mxR = -1, mxC = -1;
  for (int i = 0; i < rw; i++) {
    for (int j = 0; j < cl; j++) {
      if (arr[i][j] == '*') {
        mnR = min(i, mnR);
        mxR = max(mxR, i);
        mnC = min(mnC, j);
        mxC = max(mxC, j);
      }
    }
  }
  for (int i = mnR; i <= mxR; i++) {
    for (int j = mnC; j <= mxC; j++) {
      cout << arr[i][j];
    }
    if (i != mxR) cout << endl;
  }
}
