#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
int N, M;
const int maxn = 55;
char Map[maxn][maxn];
int main() {
  while (scanf("%d%d", &N, &M) != EOF) {
    for (int i = 0; i < N; i++) cin >> Map[i];
    int xmin = 50, xmax = 0, ymin = 50, ymax = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < M; j++) {
        if (Map[i][j] == '*') {
          xmin = min(i, xmin);
          xmax = max(i, xmax);
          ymin = min(j, ymin);
          ymax = max(j, ymax);
        }
      }
    }
    for (int i = xmin; i <= xmax; i++) {
      for (int j = ymin; j <= ymax; j++) printf("%c", Map[i][j]);
      printf("\n");
    }
  }
  return 0;
}
