#include <bits/stdc++.h>
char s[2222][2222] = {0};
int m, n;
void find(int x, int y) {
  if (!x || !y || x == m || y == n) return;
  int cnt = 0;
  for (int i = 0; i <= 1; i++)
    for (int j = 0; j <= 1; j++) cnt += (s[x + i][y + j] == '.');
  if (cnt == 3) {
    for (int i = 0; i <= 1; i++)
      for (int j = 0; j <= 1; j++) s[x + i][y + j] = '.';
    for (int i = -1; i <= 1; i++)
      for (int j = -1; j <= 1; j++) find(x + i, y + j);
  }
}
int main() {
  scanf("%d%d", &m, &n);
  for (int i = 1; i <= m; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i < m; i++)
    for (int j = 1; j < n; j++) find(i, j);
  for (int i = 1; i <= m; i++) printf("%s\n", s[i] + 1);
  return 0;
}
