#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  char arr[n][m];
  int rowMin = -1, colMin = -1, rowMax = -1, colMax = -1;
  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] == '*') {
        rowMin = rowMax = i;
        colMin = colMax = j;
        break;
      }
    }
    if (rowMin != -1) break;
  }
  for (int i = rowMin; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == '*') {
        if (j < colMin) colMin = j;
        if (j > colMax) colMax = j;
        if (i > rowMax) rowMax = i;
      }
    }
  }
  for (int i = rowMin; i <= rowMax; i++) {
    for (int j = colMin; j <= colMax; j++) {
      cout << arr[i][j];
    }
    cout << "\n";
  }
  return 0;
}
