#include <bits/stdc++.h>
using namespace std;
void ret(string s) {
  cout << s;
  exit(0);
}
int main() {
  int n, m;
  cin >> n >> m;
  bool ok;
  string s[100];
  int xn = 200, xm = 0, yn = 200, ym = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < s[i].length(); j++)
      if (s[i][j] == '*') {
        xn = min(xn, j);
        xm = max(xm, j);
        yn = min(yn, i);
        ym = max(yn, i);
      }
  }
  for (int i = yn; i <= ym; i++) {
    for (int j = xn; j <= xm; j++) cout << s[i][j];
    printf("\n");
  }
  return 0;
}
