#include <bits/stdc++.h>
using namespace std;
char a[55][55];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  int b1 = 0, b2 = 0, b3 = 0, b4 = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == '*') {
        b1 = i;
        break;
      }
    }
    if (b1 != 0) break;
  }
  for (int i = n; i >= 1; i--) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == '*') {
        b2 = i;
        break;
      }
    }
    if (b2 != 0) break;
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[j][i] == '*') {
        b3 = i;
        break;
      }
    }
    if (b3 != 0) break;
  }
  for (int i = m; i >= 1; i--) {
    for (int j = 1; j <= n; j++) {
      if (a[j][i] == '*') {
        b4 = i;
        break;
      }
    }
    if (b4 != 0) break;
  }
  for (int i = b1; i <= b2; i++) {
    for (int j = b3; j <= b4; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}
