#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  cin >> m;
  char **p;
  char s;
  p = new char *[n];
  for (int i = 0; i < n; i++) *(p + i) = new char[m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> s;
      *(*(p + i) + j) = s;
    }
  }
  int minc = m;
  int maxc = 0;
  for (int j = 0; j < m; j++) {
    bool f = false;
    for (int i = 0; i < n; i++) {
      if (*(*(p + i) + j) == '*') f = true;
    }
    if (f == true) {
      maxc = j;
      if (j < minc) minc = j;
    }
  }
  int minr = n;
  int maxr = 0;
  for (int i = 0; i < n; i++) {
    bool f = false;
    for (int j = 0; j < m; j++) {
      if (*(*(p + i) + j) == '*') f = true;
    }
    if (f == true) {
      maxr = i;
      if (i < minr) minr = i;
    }
  }
  for (int i = minr; i <= maxr; i++) {
    for (int j = minc; j <= maxc; j++) cout << *(*(p + i) + j);
    cout << endl;
  }
  return 0;
}
