#include <bits/stdc++.h>
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int min_row = n, max_row = 0, min_col = m, max_col = 0;
  char S[105][105];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf(" %c", &S[i][j]);
      if (S[i][j] == '*') {
        min_row = std::min(min_row, i), max_row = std::max(max_row, i),
        min_col = std::min(min_col, j), max_col = std::max(max_col, j);
      }
    }
  }
  for (int i = min_row; i <= max_row; i++, putchar('\n')) {
    for (int j = min_col; j <= max_col; j++) {
      printf("%c", S[i][j]);
    }
  }
  return 0;
}
