#include <bits/stdc++.h>
using namespace std;
int table[1000][1000];
int main(void) {
  bool star = false;
  char arr[50][50];
  bool row[50], column[50];
  memset(row, true, sizeof(row));
  memset(column, true, sizeof(column));
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
      if (arr[i][j] == '*') {
        star = true;
        row[i] = false;
        column[j] = false;
      }
    }
  }
  if (!star) {
    cout << endl;
  } else {
    int l = 0, r = m - 1, u = 0, d = n - 1;
    while (l < m && column[l] == true) l++;
    while (r >= 0 && column[r] == true) r--;
    while (u < n && row[u] == true) u++;
    while (d >= 0 && row[d] == true) d--;
    for (int i = u; i <= d; i++) {
      for (int j = l; j <= r; j++) {
        cout << arr[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}
