#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  int left = m, right = -1, top = n, bottom = -1;
  for (int i = 0; i < n; i++) {
    string& row = s[i];
    for (int j = 0; j < m; j++) {
      if (row[j] == '*') {
        left = min(left, j);
        right = max(right, j);
        top = min(top, i);
        bottom = max(bottom, i);
      }
    }
  }
  for (int i = top; i <= bottom; i++) {
    cout << s[i].substr(left, (right - left) + 1) << '\n';
  }
  cout.flush();
  return 0;
}
