#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[50][51];
  int i, j, len, row_s = 50, row_e = 0, col_s = 50, col_e = 0, n, width;
  bool rs, re;
  cin >> n >> width;
  for (i = 0; i < n; i++) {
    re = false;
    rs = false;
    for (j = 0; j < width; j++) {
      cin >> str[i][j];
      if (str[i][j] == '*') {
        if (col_s > j) col_s = j;
        if (col_e < j) col_e = j;
        rs = true;
        re = true;
      }
    }
    if (rs && row_s == 50) row_s = i;
    if (re) row_e = i;
  }
  for (i = row_s; i <= row_e; i++) {
    for (j = col_s; j <= col_e; j++) printf("%c", str[i][j]);
    if (i <= row_e) printf("\n");
  }
  return 0;
}
