#include <bits/stdc++.h>
char ans[55][55];
int main() {
  int m, n;
  int a, b, c, d;
  scanf("%d%d", &m, &n);
  getchar();
  int i, j;
  c = d = a = b = -1;
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      scanf("%c", &ans[i][j]);
      if (ans[i][j] == '*' && a == -1 && b == -1) {
        a = c = i;
        b = d = j;
      } else if (ans[i][j] == '*') {
        c = i;
        if (j > d) d = j;
        if (j < b) b = j;
      }
    }
    getchar();
  }
  if (a != -1)
    for (i = a; i <= c; i++) {
      for (j = b; j <= d; j++) printf("%c", ans[i][j]);
      printf("\n");
    }
  printf("\n");
  return 0;
}
