#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m;
  pair<int, int> tl = {-100, -100}, br = {-100, -100};
  cin >> n >> m;
  char paper[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> paper[i][j];
      if (paper[i][j] == '*' && (tl.first == -100 && tl.second == -100))
        tl = {i, j};
      else if (j < tl.second && paper[i][j] == '*')
        tl = {tl.first, j};
      if (paper[i][j] == '*' && (i >= br.first && j > br.second))
        br = {i, j};
      else if (paper[i][j] == '*' && (i > br.first))
        br = {i, br.second};
      else if (paper[i][j] == '*' && (j > br.second))
        br = {br.first, j};
    }
  }
  for (int i = tl.first; i <= br.first; i++) {
    for (int j = tl.second; j <= br.second; j++) {
      cout << paper[i][j];
    }
    cout << "\n";
  }
  return 0;
}
