#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  char ch[52][52];
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> ch[i][j];
    }
  }
  int x1 = -1, x2 = 52, y1 = -1, y2 = 52;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ch[i][j] == '*') {
        if (i > x1) x1 = i;
        if (i < x2) x2 = i;
        if (j > y1) y1 = j;
        if (j < y2) y2 = j;
      }
    }
  }
  for (int i = x2; i <= x1; i++) {
    for (int j = y2; j <= y1; j++) {
      cout << ch[i][j];
    }
    cout << endl;
  }
  return 0;
}
