#include <bits/stdc++.h>
using namespace std;
int a, b, mn = 1000000009, mx;
char c[59][59];
int ist, ien;
bool w;
int main() {
  cin >> a >> b;
  for (int i = 1; i <= a; i++)
    for (int j = 1; j <= b; j++) {
      cin >> c[i][j];
      if (c[i][j] == '*')
        mn = min(j, mn), mx = max(j, mx), (w == 0 ? ist = i : ist = ist),
        ien = i, w = 1;
    }
  for (int i = ist; i <= ien; i++) {
    for (int j = mn; j <= mx; j++) cout << c[i][j];
    cout << endl;
  }
  return 0;
}
