#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  vector<string> grid;
  string row;
  for (long long int i = 0; i < n; ++i) {
    cin >> row;
    grid.push_back(row);
  }
  long long int first_row = -1;
  for (long long int i = 0; i < n; ++i) {
    bool found = false;
    for (long long int j = 0; j < m; ++j) {
      if (grid[i][j] == '*') {
        found = true;
        break;
      }
    }
    if (found) {
      first_row = i;
      break;
    }
  }
  long long int last_row = -1;
  for (long long int i = n - 1; i >= 0; --i) {
    bool found = false;
    for (long long int j = 0; j < m; ++j) {
      if (grid[i][j] == '*') {
        found = true;
        break;
      }
    }
    if (found) {
      last_row = i;
      break;
    }
  }
  long long int first_col = -1;
  for (long long int j = 0; j < m; ++j) {
    bool found = false;
    for (long long int i = 0; i < n; ++i) {
      if (grid[i][j] == '*') {
        found = true;
        break;
      }
    }
    if (found) {
      first_col = j;
      break;
    }
  }
  long long int last_col = -1;
  for (long long int j = m - 1; j >= 0; --j) {
    bool found = false;
    for (long long int i = 0; i < n; ++i) {
      if (grid[i][j] == '*') {
        found = true;
        break;
      }
    }
    if (found) {
      last_col = j;
      break;
    }
  }
  for (int i = first_row; i <= last_row; ++i) {
    for (int j = first_col; j <= last_col; ++j) {
      cout << grid[i][j];
    }
    cout << endl;
  }
  return 0;
}
