#include <bits/stdc++.h>
int n, m, qi[0x400000], qj[0x400000], ql, qr;
char s[2048][2048], v[2048][2048];
static inline void push(int i, int j) {
  if (v[i][j] || i < 1 || i > n || j < 1 || j > m) return;
  s[i][j] = '.';
  v[i][j] = 1;
  qi[qr] = i;
  qj[qr] = j;
  ++qr;
}
static inline void pop(int &i, int &j) {
  i = qi[ql];
  j = qj[ql];
  ++ql;
}
static inline bool illegal(int i, int j, int &p, int &q) {
  int cnt = 0;
  for (int k = 0; k < 2; ++k)
    for (int l = 0; l < 2; ++l)
      if (s[i + k][j + l] == '*') {
        p = i + k;
        q = j + l;
        ++cnt;
      }
  return cnt == 1;
}
static inline void expend(int i, int j) {
  int k, l, p, q;
  for (k = -2; k <= 2; ++k)
    for (l = -2; l <= 2; ++l)
      if (illegal(i + l, j + k, p, q)) push(p, q);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%s", s[i] + 1);
  for (int i = 0; i <= n + 1; ++i) s[i][0] = s[i][m + 1] = '*';
  for (int i = 1; i <= m; ++i) s[0][i] = s[n + 1][i] = '*';
  while (true) {
    bool f = false;
    ql = qr = 0;
    memset(v, 0, sizeof(v));
    for (int i = 1, p, q; i + 1 <= n; ++i)
      for (int j = 1; j + 1 <= m; ++j)
        if (f = illegal(i, j, p, q)) {
          push(p, q);
        }
    for (int i, j; qr - ql > 0;) {
      pop(i, j);
      expend(i, j);
    }
    if (!f) break;
  }
  for (int i = 1; i <= n; ++i) {
    s[i][m + 1] = 0;
    printf("%s\n", s[i] + 1);
  }
  return 0;
}
