#include <bits/stdc++.h>
using namespace std;
int n, m, r1 = 55, r2 = 55, c1 = 55, c2 = 55, i, j;
char a[55][55];
int main() {
  cin >> n >> m;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) cin >> a[i][j];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++)
      if (a[i][j] == '*') {
        r1 = i;
        break;
      }
    if (r1 == i) break;
  }
  for (i = n - 1; i >= 0; i--) {
    for (j = 0; j < m; j++)
      if (a[i][j] == '*') {
        r2 = i;
        break;
      }
    if (r2 == i) break;
  }
  for (j = 0; j < m; j++) {
    for (i = 0; i < n; i++)
      if (a[i][j] == '*') {
        c1 = j;
        break;
      }
    if (c1 == j) break;
  }
  for (j = m - 1; j >= 0; j--) {
    for (i = 0; i < n; i++)
      if (a[i][j] == '*') {
        c2 = j;
        break;
      }
    if (c2 == j) break;
  }
  for (i = r1; i <= r2; i++) {
    for (j = c1; j <= c2; j++) cout << a[i][j];
    cout << endl;
  }
  return 0;
}
