#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, c;
  vector<int> row, col;
  cin >> r >> c;
  string s[1000];
  for (int i = 0; i < r; i++) cin >> s[i];
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++)
      if (s[i][j] == '*') row.push_back(i), col.push_back(j);
  sort(row.begin(), row.end());
  sort(col.begin(), col.end());
  int minr = row[0];
  int maxr = row[row.size() - 1];
  int minc = col[0];
  int maxc = col[row.size() - 1];
  for (int i = minr; i <= maxr; i++) {
    for (int j = minc; j <= maxc; j++) {
      cout << s[i][j];
    }
    cout << endl;
  }
  return 0;
}
