#include <bits/stdc++.h>
int main() {
  char graph[50][50];
  int m, n, i, j;
  int first_in_row, last_in_row, first_row, last_row;
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf(" %c", &graph[i][j]);
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (graph[i][j] == '*') {
        first_in_row = j;
        last_in_row = j;
        first_row = i;
        last_row = i;
        goto loop_break;
      }
    }
  }
loop_break:
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (graph[i][j] == '*') {
        if (j < first_in_row) first_in_row = j;
        if (j > last_in_row) last_in_row = j;
        if (i > last_row) last_row = i;
      }
    }
  }
  for (i = first_row; i <= last_row; i++) {
    for (j = first_in_row; j <= last_in_row; j++) {
      printf("%c", graph[i][j]);
    }
    printf("\n");
  }
  return 0;
}
