#include <bits/stdc++.h>
using namespace std;
int i, j, k;
int main() {
  int n, m, a, b, c = 10000000, d = -1, e, f;
  cin >> n >> m;
  string s[50];
  for (i = 0; i < n; i++) cin >> s[i];
  for (i = 0; i < n; i++)
    if (s[i].find('*') < m) {
      e = i;
      break;
    }
  for (i = n - 1; i >= 0; i--)
    if (s[i].find('*') < m) {
      f = i;
      break;
    }
  for (i = e; i <= f; i++) {
    for (j = 0; j < m; j++)
      if (s[i][j] == '*') {
        a = j;
        break;
      }
    for (j = m - 1; j >= 0; j--)
      if (s[i][j] == '*') {
        b = j;
        break;
      }
    c = min(a, c), d = max(b, d);
  }
  for (i = e; i <= f; i++) {
    for (j = c; j <= d; j++) cout << s[i][j];
    cout << endl;
  }
}
