#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
const int INF = 2e9;
const long long LINF = 9e18;
const int MOD = 2e9 + 11;
const int p = 37;
const int MAXN = 2 * 1e3;
vector<vector<int>> a(MAXN, vector<int>(MAXN));
vector<vector<bool>> updated(MAXN, vector<bool>(MAXN, false));
int n, m;
const int DX1[] = {0, 1, 0, 1};
const int DY1[] = {0, 0, -1, -1};
const int DX2[] = {0, 0, 1, 1};
const int DY2[] = {0, 1, 0, 1};
const int DX3[] = {0, 0, -1, -1};
const int DY3[] = {0, 1, 0, 1};
const int DX4[] = {0, -1, 0, -1};
const int DY4[] = {0, 0, -1, -1};
void check2(int x1, int y1, pii& s1, int& cnt1) {
  if (x1 >= 0 && x1 < m && y1 >= 0 && y1 < n) {
    cnt1 += a[y1][x1];
    if (a[y1][x1] == 1) s1 = {y1, x1};
  } else
    cnt1 = -10;
}
void check3(int cnt, pii s, queue<pii>& q) {
  if (cnt == 1) {
    q.push(s);
  }
}
void check(pii cur, queue<pii>& q) {
  int cnt1, cnt2, cnt3, cnt4;
  cnt1 = cnt2 = cnt3 = cnt4 = 0;
  int x = cur.second;
  int y = cur.first;
  if (updated[y][x]) return;
  a[y][x] = 0;
  updated[y][x] = true;
  pii s1, s2, s3, s4;
  for (int i = 0; i < 4; ++i) {
    int x1 = x + DX1[i];
    int y1 = y + DY1[i];
    int x2 = x + DX2[i];
    int y2 = y + DY2[i];
    int x3 = x + DX3[i];
    int y3 = y + DY3[i];
    int x4 = x + DX4[i];
    int y4 = y + DY4[i];
    check2(x1, y1, s1, cnt1);
    check2(x2, y2, s2, cnt2);
    check2(x3, y3, s3, cnt3);
    check2(x4, y4, s4, cnt4);
  }
  check3(cnt1, s1, q);
  check3(cnt2, s2, q);
  check3(cnt3, s3, q);
  check3(cnt4, s4, q);
}
void check4(int x, int y, int& cnt) {
  if (x >= 0 && x < m && y >= 0 && y < n) {
    cnt += a[y][x];
  } else
    cnt = -10;
}
bool satisfies(int y, int x) {
  int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0;
  for (int i = 0; i < 4; ++i) {
    int x1 = x + DX1[i];
    int y1 = y + DY1[i];
    int x2 = x + DX2[i];
    int y2 = y + DY2[i];
    int x3 = x + DX3[i];
    int y3 = y + DY3[i];
    int x4 = x + DX4[i];
    int y4 = y + DY4[i];
    check4(x1, y1, cnt1);
    check4(x2, y2, cnt2);
    check4(x3, y3, cnt3);
    check4(x4, y4, cnt4);
  }
  if (cnt1 == 1 || cnt2 == 1 || cnt3 == 1 || cnt4 == 1) return true;
  return false;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      char c;
      cin >> c;
      if (c == '.')
        a[i][j] = 0;
      else
        a[i][j] = 1;
    }
  }
  queue<pii> q;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i][j] == 1 && satisfies(i, j)) {
        q.push({i, j});
      }
    }
  }
  while (!q.empty()) {
    pii cur = q.front();
    q.pop();
    check(cur, q);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i][j] == 0)
        cout << '.';
      else
        cout << '*';
    }
    cout << endl;
  }
  return 0;
}
