#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, a = 100, b = 0, c = 100, d = 0;
  string *s;
  cin >> n >> m;
  s = new string[n];
  for (long long int i = 0; i < n; i++) {
    cin >> s[i];
    if (count(s[i].begin(), s[i].end(), '*')) c = min(c, i), d = max(d, i);
    for (long long int j = 0; j < m; j++)
      if (s[i][j] == '*') a = min(a, j), b = max(b, j);
  }
  for (int i = c; i <= d; i++) {
    for (int j = a; j <= b; j++) cout << s[i][j];
    cout << "\n";
  }
  return 0;
}
