#include <bits/stdc++.h>
using namespace std;
int m, n;
char s[3000][3000];
char h[3000][3000];
int bozuk(int i, int j) {
  if (s[i][j] != '*') return false;
  if (s[i - 1][j] == '.' && s[i - 1][j + 1] == '.' && s[i][j + 1] == '.') {
    return true;
  }
  if (s[i][j + 1] == '.' && s[i + 1][j + 1] == '.' && s[i + 1][j] == '.') {
    return true;
  }
  if (s[i][j - 1] == '.' && s[i + 1][j - 1] == '.' && s[i + 1][j] == '.') {
    return true;
  }
  if (s[i][j - 1] == '.' && s[i - 1][j - 1] == '.' && s[i - 1][j] == '.') {
    return true;
  }
  return false;
}
int main() {
  cin >> m >> n;
  for (long long int i = 1; i <= m; i++) scanf("%s", s[i] + 1);
  queue<pair<int, int> > Q;
  for (long long int i = 1; i <= m; i++)
    for (long long int j = 1; j <= n; j++)
      if (bozuk(i, j)) Q.push(make_pair(i, j)), h[i][j] = 1;
  int x, y, xx, yy;
  while (Q.size()) {
    x = Q.front().first;
    y = Q.front().second;
    Q.pop();
    s[x][y] = '.';
    h[x][y] = 1;
    for (long long int i = -1; i <= 1; i++)
      for (long long int j = -1; j <= 1; j++) {
        if (!i and !j) continue;
        xx = x + i;
        yy = y + j;
        if (xx < 1 or xx > m or yy < 1 or yy > n or h[xx][yy] or !bozuk(xx, yy))
          continue;
        Q.push(make_pair(xx, yy)), h[xx][yy] = 1;
        s[xx][yy] = '.';
      }
  }
  for (long long int i = 1; i <= m; i++) printf("%s\n", s[i] + 1);
}
