#include <bits/stdc++.h>
char arr[1005][1005];
int i, j, n, m, s, k = 100000, d = -100000, b = 100000, g = -100000, e;
int main() {
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      scanf(" %c", &arr[i][j]);
      if (arr[i][j] == '*') {
        if (j > d) d = j;
        if (j < b) b = j;
        if (i > g) g = i;
        if (i < k) k = i;
      }
    }
  for (i = k; i <= g; i++) {
    for (j = b; j <= d; j++) printf("%c", arr[i][j]);
    puts("");
  }
  return 0;
}
