#include <bits/stdc++.h>
using namespace std;
const int maxn = 2002;
int n, m, i, j;
char a[maxn][maxn];
void enter() {
  cin >> n >> m;
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j) cin >> a[i][j];
}
void dfs(int x, int y) {
  if (x < 0 || y < 0 || x == n || y == m) return;
  int cnt = 0;
  for (int i = (0); i <= (1); ++i)
    for (int j = (0); j <= (1); ++j) cnt += (a[x + i][y + j] == '.');
  if (cnt == 3) {
    for (int i = (0); i <= (1); ++i)
      for (int j = (0); j <= (1); ++j) a[x + i][y + j] = '.';
    for (int i = (-1); i <= (1); ++i)
      for (int j = (-1); j <= (1); ++j)
        if (i || j) dfs(x + i, y + j);
  }
}
void process() {
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j) dfs(i, j);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  enter();
  process();
  for (int i = (0); i < (n); ++i) {
    for (int j = (0); j < (m); ++j) cout << a[i][j];
    cout << '\n';
  }
  return 0;
}
