#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  string paper[52];
  scanf("%d%d ", &n, &m);
  for (int i = 0; i < n; i++) {
    cin >> paper[i];
  }
  int kiri = m, kanan = -1, atas = n, bawah = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (paper[i][j] == '*') {
        if (kiri > j) kiri = j;
        if (kanan < j) kanan = j;
        if (atas > i) atas = i;
        if (bawah < i) bawah = i;
      }
    }
  }
  for (int i = atas; i <= bawah; i++) {
    for (int j = kiri; j <= kanan; j++) {
      printf("%c", paper[i][j]);
    }
    printf("\n");
  }
  return 0;
}
