#include <bits/stdc++.h>
using namespace std;
char a[55][55];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  int x = 0, y = n, u = 0, v = m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '*') {
        if (i >= x) x = i;
        if (i <= y) y = i;
        if (j >= u) u = j;
        if (j <= v) v = j;
      }
    }
  }
  for (int i = y; i <= x; i++) {
    for (int j = v; j <= u; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }
}
