#include <bits/stdc++.h>
using namespace std;
template <typename T>
T BigMod(T b, T p, T m) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    T s = BigMod(b, p / 2, m);
    return ((s % m) * (s % m)) % m;
  }
  return ((b % m) * (BigMod(b, p - 1, m) % m)) % m;
}
template <typename T>
T ModInv(T b, T m) {
  return BigMod(b, m - 2, m);
}
template <typename T>
T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <typename T>
T euclide(T a, T b, T &x, T &y) {
  if (a < 0) {
    T d = euclide(-a, b, x, y);
    x = -x;
    return d;
  }
  if (b < 0) {
    T d = euclide(a, -b, x, y);
    y = -y;
    return d;
  }
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    T d = euclide(b, a % b, x, y);
    T t = x;
    x = y;
    y = t - (a / b) * y;
    return d;
  }
}
vector<string> split(const string &s, char d) {
  stringstream ss(s);
  string i;
  vector<string> e;
  while (getline(ss, i, d)) e.push_back(i);
  return e;
}
int Set(int n, int p) { return n | (1 << p); }
int Reset(int n, int p) { return n & ~(1 << p); }
bool Check(int n, int p) { return (bool)(n & (1 << p)); }
template <class T, class X>
inline T Toggle(T a, X i) {
  T t = 1;
  return (a ^ (t << i));
}
template <typename T, typename O>
void ForEach(T c, O o) {
  for_each(c.begin(), c.end(), o);
}
template <typename T, typename O>
T Map(T c, O o) {
  transform(c.begin(), c.end(), c.begin(), o);
  return c;
}
template <typename T, typename O>
T Zip(T fc, T sc, O o) {
  transform(fc.begin(), fc.end(), sc.begin(), fc.begin(), o);
  return fc;
}
template <typename T, typename N>
bool Exist(T c, N n) {
  return find_if(c.begin(), c.end(), n) != c.end();
}
template <typename T, typename P>
T FilterNot(T c, P p) {
  auto it = remove_if(c.begin(), c.end(), p);
  c.erase(it, end(c));
  return c;
}
template <typename T, typename P>
T Filter(T c, P p) {
  auto q = [p](typename T::value_type i) { return !p(i); };
  return FilterNot(c, q);
}
void chop(vector<string> &v) {
  for (int i = (0); i < (v.size()); ++i) {
    if (v[i].find('*') != string::npos) {
      v.erase(v.begin(), v.begin() + i);
      return;
    }
  }
}
void transpose(vector<string> &v) {
  vector<string> t;
  for (auto &s : v) {
    for (int i = (0); i < (s.length()); ++i) {
      if (t.size() <= i) t.push_back("");
      t[i] += s[i];
    }
  }
  v.swap(t);
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<string>(b);
  cin.ignore();
  for (int i = (0); i < (n); ++i) {
    string s;
    getline(cin, s);
    b.push_back(s);
  }
  chop(b);
  reverse(b.begin(), b.end());
  chop(b);
  reverse(b.begin(), b.end());
  transpose(b);
  chop(b);
  reverse(b.begin(), b.end());
  chop(b);
  reverse(b.begin(), b.end());
  transpose(b);
  for (auto &v : b) cout << v << '\n';
  return 0;
}
