#include <bits/stdc++.h>
using namespace std;
const int MAXN = 55;
char a[MAXN][MAXN];
int m, n;
int main() {
  scanf("%d%d", &m, &n);
  getchar();
  int xmin, ymin, xmax, ymax;
  xmin = ymin = MAXN;
  xmax = ymax = -MAXN;
  for (int i = 0; i < m; i++) gets(a[i]);
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++)
      if (a[i][j] == '*') {
        if (xmin > j) xmin = j;
        if (ymin > i) ymin = i;
        if (xmax < j) xmax = j;
        if (ymax < i) ymax = i;
      }
  for (int i = ymin; i <= ymax; i++) {
    for (int j = xmin; j <= xmax; j++) printf("%c", a[i][j]);
    printf("\n");
  }
  return 0;
}
