#include <bits/stdc++.h>
using namespace std;
char mat[100][100];
int main(void) {
  int minyX = (1 << 30), minyY = (1 << 30), maxyX = 0, maxyY = 0;
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%s", mat[i]);
    for (int j = 0; j < m; ++j) {
      if (mat[i][j] != '*') continue;
      if (i < minyX) minyX = i;
      if (i > maxyX) maxyX = i;
      if (j < minyY) minyY = j;
      if (j > maxyY) maxyY = j;
    }
  }
  for (int row = minyX; row <= maxyX; ++row) {
    for (int col = minyY; col <= maxyY; ++col) {
      printf("%c", mat[row][col]);
    }
    printf("\n");
  }
  return 0;
}
