#include <bits/stdc++.h>
char a[1001][1001];
int x, y, i, j, xl = 99999, yl = 99999, xm = -1, ym = -1;
int main() {
  scanf("%d %d", &x, &y);
  for (i = 0; i <= x - 1; i++) {
    scanf("%s", a[i]);
    for (j = 0; j <= y - 1; j++)
      if (a[i][j] == '*') {
        xl = xl < i ? xl : i;
        yl = j < yl ? j : yl;
        xm = i > xm ? i : xm;
        ym = j > ym ? j : ym;
      }
  }
  for (i = xl; i <= xm; i++) {
    for (j = yl; j <= ym; j++) printf("%c", a[i][j]);
    printf("\n");
  }
  return 0;
}
