#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
T amax(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long N = 200005, INF = 2000000000000000000;
void solve() {
  long long n, m;
  cin >> n >> m;
  long long i = 0, j = 0;
  char v[50][50];
  long long a = 1000000, b = 10000, c = 0, d = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> v[i][j];
      if (v[i][j] == '*') {
        a = min(i, a);
        b = min(j, b);
        c = max(i, c);
        d = max(j, d);
      }
    }
  }
  for (i = a; i < c + 1; i++) {
    for (j = b; j < d + 1; j++) {
      cout << v[i][j];
    }
    cout << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}
