#include <bits/stdc++.h>
using namespace std;
int main() {
  int f = 51, l = 0, lastRow = 0, firstRow = 100000;
  int r, c;
  cin >> r >> c;
  char** arr = new char*[r];
  for (int i = 0; i < r; ++i) arr[i] = new char[c];
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> arr[i][j];
      if (arr[i][j] == '*') {
        if (i < firstRow) firstRow = i;
        lastRow = i;
        if (f > j) {
          f = j;
        }
        if (l < j) {
          l = j;
        }
      }
    }
  }
  for (int i = firstRow; i <= lastRow; i++) {
    for (int j = f; j <= l; j++) {
      cout << arr[i][j];
    }
    cout << endl;
  }
}
