#include <bits/stdc++.h>
using namespace std;
int main() {
  int num1, num2;
  while (cin >> num1 >> num2) {
    vector<string> v(num1);
    cin.get();
    for (int i = 0; i < num1; i++) getline(cin, v[i]);
    for (int i = 0; i < v.size();) {
      string s;
      for (int j = 0; j < num2; j++)
        if (v[0][j] == '*') {
          s = '&' + s;
          break;
        } else
          s += v[0][j];
      if (s == v[0])
        v.erase(v.begin());
      else
        break;
    }
    for (int i = 0; i < v.size();) {
      string s;
      for (int j = 0; j < num2; j++)
        if (v[v.size() - 1][j] == '*') {
          s = '&' + s;
          break;
        } else
          s += v[v.size() - 1][j];
      if (s == v[v.size() - 1])
        v.erase(v.end() - 1);
      else
        break;
    }
    for (int i = 0; i < v[0].length();) {
      string s;
      for (int j = 0; j < v.size(); j++)
        if (v[j][0] == '*') {
          s = '&' + s;
          break;
        } else
          s += v[j][0];
      if (s[0] != '&')
        for (int j = 0; j < v.size(); j++) v[j].erase(0, 1);
      else
        break;
    }
    for (int i = v[0].length() - 1; i >= 0;) {
      string s;
      for (int j = 0; j < v.size(); j++)
        if (v[j][v[j].length() - 1] == '*') {
          s = '&' + s;
          break;
        } else
          s += v[j][v[j].length() - 1];
      if (s[0] != '&')
        for (int j = 0; j < v.size(); j++) v[j].erase(v[j].length() - 1);
      else
        break;
    }
    if (v.size() == 0)
      cout << "*" << endl;
    else
      for (int i = 0; i < v.size(); i++) cout << v[i] << endl;
  }
}
