#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int INF = 1000000000;
int n, m;
int a, b, c, d;
char M[51][51];
int main() {
  scanf("%d %d", &n, &m);
  a = b = 60;
  for (int i = (0); i < (n); ++i) scanf("%s", M[i]);
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j)
      if (M[i][j] == '*') {
        a = min(a, i);
        b = min(b, j);
        c = max(c, i);
        d = max(d, j);
      }
  for (int i = (a); i < (c + 1); ++i) {
    M[i][d + 1] = 0;
    printf("%s\n", M[i] + b);
  }
  return 0;
}
