#include <bits/stdc++.h>
using namespace std;
void ga(int N, int *A) {
  for (int i(0); i < N; i++) scanf("%d", A + i);
}
char s[64][64];
int N, M, x = int(1e9 + 1), X, y = int(1e9 + 1), Y;
int main(void) {
  scanf("%d%d", &N, &M);
  for (int i(0); i < N; i++) scanf("%s", s[i]);
  for (int i(0); i < N; i++)
    for (int j(0); j < M; j++)
      if (s[i][j] == 42)
        x = min(x, i), X = max(X, i), y = min(y, j), Y = max(Y, j);
  for (int k(x); k < X + 1; k++) {
    for (int l(y); l < Y + 1; l++) putchar(s[k][l]);
    puts("");
  }
  return 0;
}
