#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, fr = 55, fc = 55, er = 0, ec = 0;
  char sheet[55][55];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> sheet[i][j];
      if (sheet[i][j] == '*') {
        if (i > er) er = i;
        if (j > ec) ec = j;
        if (i < fr) fr = i;
        if (j < fc) fc = j;
      }
    }
  }
  for (int i = fr; i <= er; i++) {
    for (int j = fc; j <= ec; j++) cout << sheet[i][j];
    cout << endl;
  }
  return 0;
}
