#include <bits/stdc++.h>
int main(void) {
  int i, j, n, m, mni, mnj, mxi, mxj;
  char b[100][100];
  mni = mnj = 100;
  mxi = mxj = -1;
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      scanf(" %c", &b[i][j]);
      if (b[i][j] == '*') {
        if (mni > i) mni = i;
        if (mxi < i) mxi = i;
        if (mnj > j) mnj = j;
        if (mxj < j) mxj = j;
      }
    }
  for (i = mni; i <= mxi; i++) {
    for (j = mnj; j <= mxj; j++) putchar(b[i][j]);
    putchar('\n');
  }
  return 0;
}
