#include <bits/stdc++.h>
using namespace std;
long long MOD = 998244353;
double eps = 1e-12;
int main() {
  int n, m, x = -1, y = -1, p = 100, b = -2, z = -1, r = -1;
  cin >> n >> m;
  char arr[n][m];
  for (int i = 0; i < n; ++i) {
    set<char> s;
    for (int j = 0; j < m; ++j) {
      cin >> arr[i][j];
      s.insert(arr[i][j]);
      if (arr[i][j] == '*' && x == -1) x = j;
    }
    if (p > x && x != -1) p = x;
    x = -1;
    auto v = s.begin();
    if (s.size() > 1 || (s.size() == 1 && *v == '*')) {
      if (z == -1) z = i;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--) {
      if (arr[i][j] == '*' && y == -1) y = j;
    }
    if (b < y) b = y;
    y = -1;
  }
  for (int i = n - 1; i >= 0; i--) {
    set<char> s;
    for (int j = m - 1; j >= 0; j--) {
      s.insert(arr[i][j]);
    }
    auto v = s.begin();
    if (s.size() > 1 || (s.size() == 1 && *v == '*')) {
      r = i;
      break;
    }
  }
  for (int i = z; i <= r; ++i) {
    for (int j = p; j <= b; ++j) {
      cout << arr[i][j];
    }
    cout << endl;
  }
}
