#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int x1 = 51, x2 = -1, y1 = 51, y2 = -1;
  int ri[2], li[2], di[2], ui[2];
  char p[60][60];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> p[i][j];
      if (p[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 = x1; i <= x2; i++) {
    for (int j = y1; j <= y2; j++) cout << p[i][j];
    cout << endl;
  }
  return 0;
}
