#include <bits/stdc++.h>
using namespace std;
string s[50];
int n, m;
int minx = 100, miny = 100, maxx = -100, maxy = -100;
int main() {
  cin >> n >> m;
  for (int i = 0; i < (int)(n); i++) cin >> s[i];
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(m); j++)
      if (s[i][j] == '*') {
        minx = min(minx, i);
        maxx = max(maxx, i);
        miny = min(miny, j);
        maxy = max(maxy, j);
      }
  for (int i = minx; i <= maxx; ++i)
    cout << s[i].substr(miny, maxy - miny + 1) << endl;
  return 0;
}
