#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, iMin = -1, iMax = -1, jMin = -1, jMax = -1;
  cin >> n >> m;
  char arr[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> arr[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == '*') {
        iMin = iMax = i;
        jMin = jMax = j;
        break;
      }
    }
    if (iMin >= 0) break;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == '*') {
        if (i > iMax) iMax = i;
        if (j < jMin) jMin = j;
        if (j > jMax) jMax = j;
      } else
        continue;
    }
  }
  for (int i = iMin; i <= iMax; i++) {
    for (int j = jMin; j <= jMax; j++) cout << arr[i][j];
    cout << "\n";
  }
  return 0;
}
