#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, m;
char a[2020][2020];
bool used[2020][2020];
bool check(int i, int j) { return i >= 0 && i < n && j >= 0 && j < m; }
int get(int x, int y) {
  int cnt = 0;
  for (int i = x; i <= x + 1; i++) {
    for (int j = y; j <= y + 1; j++) {
      if (check(i, j) && a[i][j] == '.') cnt++;
    }
  }
  return cnt;
}
bool process(int i, int j) {
  for (int q = i - 1; q < i + 1; q++) {
    for (int t = j - 1; t < j + 1; t++) {
      int cnt = get(q, t);
      if (cnt >= 3) return true;
    }
  }
  return false;
}
int main() {
  scanf("%d%d\n", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%c", &a[i][j]);
    }
    scanf("\n");
  }
  queue<int> Q;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '.') continue;
      if (process(i, j)) {
        Q.push(i * m + j);
        a[i][j] = '.';
      }
    }
  }
  while (!Q.empty()) {
    int x = Q.front() / m;
    int y = Q.front() % m;
    Q.pop();
    for (int k = x - 1; k <= x + 1; k++) {
      for (int t = y - 1; t <= y + 1; t++) {
        if (check(k, t) && process(k, t) && a[k][t] != '.' && !used[k][t]) {
          used[k][t] = true;
          a[k][t] = '.';
          Q.push(k * m + t);
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      printf("%c", a[i][j]);
    }
    printf("\n");
  }
  return 0;
}
