#include <bits/stdc++.h>
using namespace std;
int main() {
  int num1, num2;
  cin >> num1 >> num2;
  char arr[num1][num2];
  int raw, doneraw = 0;
  ;
  for (int i = 0; i < num1; i++) {
    for (int k = 0; k < num2; k++) {
      cin >> arr[i][k];
      if (arr[i][k] == '*' && doneraw == 0) {
        doneraw = 1;
        raw = i;
      }
    }
  }
  int colom, donecolom = 1;
  ;
  for (int i = 0; i < num1; i++) {
    for (int k = 0; k < num2; k++) {
      if (arr[i][k] == '*') {
        if (donecolom == 1) {
          colom = k;
          donecolom = 0;
        } else if (donecolom == 0) {
          if (k < colom) colom = k;
        }
      }
    }
  }
  int fraw, fcolom;
  int donefraw = 0, donefcolom = 0;
  for (int i = num1 - 1; i >= 0; i--) {
    for (int k = num2 - 1; k >= 0; k--) {
      if (arr[i][k] == '*') {
        if (donefraw == 0) {
          fraw = i;
          donefraw = 1;
        }
        if (donefcolom == 0) {
          fcolom = k;
          donefcolom = 1;
        } else if (donefcolom == 1) {
          if (k > fcolom) fcolom = k;
        }
      }
    }
  }
  for (int i = raw; i <= fraw; i++) {
    for (int k = colom; k <= fcolom; k++) {
      cout << arr[i][k];
    }
    cout << endl;
  }
  return 0;
}
