#include <bits/stdc++.h>
using namespace std;
char a[100 + 5][100 + 5];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int imin = 0x3f3f3f3f, imax = -0x3f3f3f3f, jmin = 0x3f3f3f3f,
      jmax = -0x3f3f3f3f;
  for (int i = 0; i < n; i++) {
    getchar();
    for (int j = 0; j < m; j++) {
      a[i][j] = getchar();
      if (a[i][j] == '*') {
        imin = min(i, imin);
        imax = max(i, imax);
        jmin = min(j, jmin);
        jmax = max(j, jmax);
      }
    }
  }
  for (int i = imin; i <= imax; i++) {
    for (int j = jmin; j <= jmax; j++) {
      printf("%c", a[i][j]);
    }
    printf("\n");
  }
  return 0;
}
