#include <bits/stdc++.h>
using namespace std;
int main() {
  int Nlines, Mcoulms;
  cin >> Nlines >> Mcoulms;
  string PIC[Nlines];
  bool flage = false;
  vector<int> iValues;
  vector<int> jValues;
  for (int i = 0; i < Nlines; i++) {
    cin >> PIC[i];
  }
  if ((Nlines == 1) && (Mcoulms == 1)) {
    cout << '*';
    return 0;
  }
  for (int i = 0; i < Nlines; i++) {
    string s = PIC[i];
    for (int j = 0; j < Mcoulms; j++) {
      if (s[j] == '*') {
        iValues.push_back(i);
        break;
      }
    }
  }
  for (int j = 0; j < Mcoulms; j++) {
    for (int i = 0; i < Nlines; i++) {
      string s = PIC[i];
      if (s[j] == '*') {
        jValues.push_back(j);
        break;
      }
    }
  }
  int swap;
  for (int i = 0; i < jValues.size() - 1; i++) {
    for (int j = i + 1; j < jValues.size(); j++) {
      if (jValues[j] < jValues[i]) {
        swap = jValues[i];
        jValues[i] = jValues[j];
        jValues[j] = swap;
      }
    }
  }
  for (int i = iValues[0]; i <= iValues[iValues.size() - 1]; i++) {
    for (int j = jValues[0]; j <= jValues[jValues.size() - 1]; j++) {
      cout << PIC[i][j];
    }
    cout << endl;
  }
  return 0;
}
