#include <bits/stdc++.h>
using namespace std;
const int N = 55;
const int INF = N;
int xL = INF, yU = INF, xR, yD;
int n, m;
char s[N][N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> s[i][j];
      if (s[i][j] == '*') {
        xL = min(xL, i);
        yU = min(yU, j);
        xR = max(xR, i);
        yD = max(yD, j);
      }
    }
  }
  for (int i = xL; i <= xR; ++i) {
    for (int j = yU; j <= yD; ++j) {
      printf("%c", s[i][j]);
    }
    printf("\n");
  }
}
