#include <bits/stdc++.h>
using namespace std;
long long n, m, x = 2100000000, y = 2100000000, x11, y11;
string st[100 + 10];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> st[i];
    for (int j = 0; j < m; j++) {
      if (st[i][j] == '*' && i < x) x = i;
      if (st[i][j] == '*' && j < y) y = j;
      if (st[i][j] == '*' && i > x11) x11 = i;
      if (st[i][j] == '*' && j > y11) y11 = j;
    }
  }
  for (int i = x; i <= x11; i++) {
    for (int j = y; j <= y11; j++) {
      cout << st[i][j];
    }
    cout << endl;
  }
  return 0;
}
