#include <bits/stdc++.h>
using namespace std;
int main() {
  char st[55][55];
  int n, m, s = 0, i, j, k = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", st[i]);
  }
  for (int i = 1; i <= n; i++) {
    s = 0;
    for (int j = 0; j < m; j++) {
      if (st[i][j] == '.') s++;
    }
    if (s == m) {
      for (int j = 0; j < m; j++) {
        st[i][j] = 'x';
      }
    } else
      break;
  }
  for (int i = n; i >= 1; i--) {
    s = 0;
    for (int j = 0; j < m; j++) {
      if (st[i][j] == '.') s++;
    }
    if (s == m) {
      for (int j = 0; j < m; j++) {
        st[i][j] = 'x';
      }
    } else
      break;
  }
  for (int j = 0; j < m; j++) {
    s = 0;
    for (int i = 1; i <= n; i++) {
      if (st[i][j] == 'x' || st[i][j] == '.') s++;
    }
    if (s == n) {
      for (int i = 1; i <= n; i++) {
        st[i][j] = 'x';
      }
    } else
      break;
  }
  for (int j = m - 1; j >= 0; j--) {
    s = 0;
    for (int i = 1; i <= n; i++) {
      if (st[i][j] == 'x' || st[i][j] == '.') s++;
    }
    if (s == n) {
      for (int i = 1; i <= n; i++) {
        st[i][j] = 'x';
      }
    } else
      break;
  }
  for (int i = 1; i <= n; i++) {
    k = 0;
    for (int j = 0; j <= m; j++) {
      if (st[i][j] == '*' || st[i][j] == '.') {
        k = 1;
        printf("%c", st[i][j]);
      }
    }
    if (k == 1) printf("\n");
  }
  return 0;
}
