#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
void Fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long fact(long long n) {
  long long f = 1;
  for (int i = 2; i <= n; i++) {
    f *= i;
  }
  return f;
}
long long ncr(long long n, long long r) {
  return fact(n) / (fact(r) * fact(n - r));
}
long long npr(long long n, long long r) { return fact(n) / fact(n - r); }
bool prime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return 0;
      break;
    }
  }
  return 1;
}
char arr[55][55];
void solve() {
  int n, m;
  cin >> n >> m;
  int r1 = INT_MIN, r2 = INT_MAX, c1 = INT_MIN, c2 = INT_MAX;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
      if (arr[i][j] == '*') {
        r1 = max(r1, i);
        r2 = min(r2, i);
        c1 = max(c1, j);
        c2 = min(c2, j);
      }
    }
  }
  for (int i = r2; i <= r1; i++) {
    for (int j = c2; j <= c1; j++) {
      cout << arr[i][j];
    }
    cout << "\n";
  }
}
int main() {
  Fast();
  solve();
  return 0;
}
