#include <bits/stdc++.h>
using namespace std;
const int MAX = 51;
int n, m;
char a[MAX][MAX];
void solve() {
  int i, j, minr = 52, maxr = -1, minl = 52, maxl = -1;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (a[i][j] == '*') {
        minr = min(minr, i);
        maxr = max(maxr, i);
        minl = min(minl, j);
        maxl = max(maxl, j);
      }
    }
  }
  for (i = minr; i <= maxr; i++) {
    for (j = minl; j <= maxl; j++) {
      printf("%c", a[i][j]);
    }
    puts("");
  }
}
int main() {
  int i, j;
  while (scanf("%d%d", &n, &m) == 2) {
    getchar();
    for (i = 0; i < n; i++) {
      gets(a[i]);
    }
    solve();
  }
  fclose(stdin);
  fclose(stdout);
  return 0;
}
