#include <bits/stdc++.h>
int main() {
  int a[55][55], p, q, x, y, i, j, t, r, c;
  char ch;
  while (scanf("%d%d\n", &r, &c) == 2) {
    p = r;
    q = 1;
    x = c;
    y = 1;
    t = 0;
    for (i = 1; i <= r; i++) {
      for (j = 1; j <= c; j++) {
        scanf("%c", &ch);
        if (ch == '*') {
          if (i < p) p = i;
          if (i > q) q = i;
          if (j < x) x = j;
          if (j > y) y = j;
          t = 1;
          a[i][j] = 1;
        } else
          a[i][j] = 0;
      }
      scanf("%c", &ch);
    }
    if (t) {
      for (i = p; i <= q; i++) {
        for (j = x; j <= y; j++)
          if (a[i][j] == 1)
            printf("*");
          else
            printf(".");
        printf("\n");
      }
    }
  }
  return 0;
}
