#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[50][50];
  int m, n, rmax, rmin, cmax, cmin, i, j;
  cin >> m >> n;
  for (i = 0; i < m; i++)
    for (j = 0; j < n; j++) cin >> a[i][j];
  for (i = 0; i < m; i++)
    for (j = 0; j < n; j++) {
      if (a[i][j] == '*') {
        rmax = i;
        break;
      }
    }
  for (j = 0; j < n; j++)
    for (i = 0; i < m; i++) {
      if (a[i][j] == '*') {
        cmax = j;
        break;
      }
    }
  for (i = m - 1; i >= 0; i--)
    for (j = n - 1; j >= 0; j--) {
      if (a[i][j] == '*') {
        rmin = i;
        break;
      }
    }
  for (j = n - 1; j >= 0; j--)
    for (i = m - 1; i >= 0; i--) {
      if (a[i][j] == '*') {
        cmin = j;
        break;
      }
    }
  for (i = rmin; i <= rmax; i++) {
    for (j = cmin; j <= cmax; j++) cout << a[i][j];
    cout << "\n";
  }
  return 0;
}
