#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, m, xa = 55, xb = -1, ya = 55, yb = -1;
  char g[50][50];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> g[i][j];
      if (g[i][j] == '*') {
        xa = min(i, xa);
        ya = min(j, ya);
        xb = max(i, xb);
        yb = max(j, yb);
      }
    }
  }
  for (int i = xa; i <= xb; i++) {
    for (int j = ya; j <= yb; j++) {
      cout << g[i][j];
    }
    puts("");
  }
  return 0;
}
