#include <bits/stdc++.h>
using namespace std;
char ma[100][100];
int main() {
  int xi = 0, xs = 10000, yi = 0, ys = 10000;
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      scanf(" %c ", &ma[i][j]);
      if (ma[i][j] == '*') {
        xs = min(xs, i);
        ys = min(ys, j);
        xi = max(xi, i);
        yi = max(yi, j);
      }
    }
  for (int i = xs; i <= xi; i++) {
    for (int j = ys; j <= yi; j++) {
      printf("%c", ma[i][j]);
    }
    printf("\n");
  }
  return 0;
}
