#include <bits/stdc++.h>
using namespace std;
const int N = 2100;
const int dx[] = {0, 0, 1, -1, 1, -1, -1, 1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
bool vis[N][N];
char s[N][N];
queue<int> qx, qy;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i < n; i++)
    for (int j = 1; j < m; j++) {
      if (s[i][j] == '.' && s[i][j + 1] == '.' && s[i + 1][j] == '.' &&
          s[i + 1][j + 1] == '*')
        s[i + 1][j + 1] = '.', vis[i + 1][j + 1] = 1, qx.push(i + 1),
                     qy.push(j + 1);
      if (s[i][j] == '*' && s[i][j + 1] == '.' && s[i + 1][j] == '.' &&
          s[i + 1][j + 1] == '.')
        s[i][j] = '.', vis[i][j] = 1, qx.push(i), qy.push(j);
      if (s[i][j] == '.' && s[i][j + 1] == '*' && s[i + 1][j] == '.' &&
          s[i + 1][j + 1] == '.')
        s[i][j + 1] = '.', vis[i][j + 1] = 1, qx.push(i), qy.push(j + 1);
      if (s[i][j] == '.' && s[i][j + 1] == '.' && s[i + 1][j] == '*' &&
          s[i + 1][j + 1] == '.')
        s[i + 1][j] = '.', vis[i + 1][j] = 1, qx.push(i + 1), qy.push(j);
    }
  while (!qx.empty()) {
    int ux = qx.front(), uy = qy.front();
    qx.pop();
    qy.pop();
    for (int i = 0; i < 8; i++) {
      int nx = ux + dx[i], ny = uy + dy[i];
      if (nx < 1 || nx > n || ny < 1 || ny > m || vis[nx][ny]) continue;
      if (s[nx][ny] == '*') {
        if (s[nx][ny + 1] == '.' && s[nx + 1][ny] == '.' &&
                s[nx + 1][ny + 1] == '.' ||
            s[nx][ny + 1] == '.' && s[nx - 1][ny] == '.' &&
                s[nx - 1][ny + 1] == '.' ||
            s[nx][ny - 1] == '.' && s[nx + 1][ny] == '.' &&
                s[nx + 1][ny - 1] == '.' ||
            s[nx][ny - 1] == '.' && s[nx - 1][ny] == '.' &&
                s[nx - 1][ny - 1] == '.') {
          s[nx][ny] = '.';
          qx.push(nx);
          qy.push(ny);
          vis[nx][ny] = 1;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) printf("%s\n", s[i] + 1);
  return 0;
}
