#include <bits/stdc++.h>
using namespace std;
char str[2010][2010];
int i, j, k;
void dfs(int a, int b) {
  if (a < 0 || b < 0 || a >= i - 1 || b >= j - 1) return;
  int p, q, r, coun = 0;
  for (p = 0; p < 2; p++) {
    for (q = 0; q < 2; q++)
      if (str[p + a][q + b] == '.') coun++;
  }
  if (coun == 3) {
    for (p = 0; p < 2; p++)
      for (q = 0; q < 2; q++) str[p + a][q + b] = '.';
    for (p = -1; p <= 1; p++)
      for (q = -1; q <= 1; q++) dfs(a + p, b + q);
  }
}
int main() {
  int l, m, n, coun;
  cin >> i >> j;
  for (k = 0; k < i; k++) {
    for (l = 0; l < j; l++) cin >> str[k][l];
  }
  for (k = 0; k < i - 1; k++) {
    for (l = 0; l < j - 1; l++) {
      dfs(k, l);
    }
  }
  for (k = 0; k < i; k++) cout << str[k] << endl;
  return 0;
}
