#include <bits/stdc++.h>
using namespace std;
inline int min(int a, int b) { return a < b ? a : b; }
inline int max(int a, int b) { return a > b ? a : b; }
char matrix[2010][2010];
struct Node {
  int x, y;
  Node(int a, int b) : x(a), y(b) {}
};
queue<Node> q;
void bfs() {
  while (!q.empty()) {
    Node node = q.front();
    q.pop();
    int x = node.x, y = node.y;
    for (int i = x - 1; i <= x; i++) {
      for (int j = y - 1; j <= y; j++) {
        int tx, ty, p = 0;
        for (int k = i; k <= i + 1; k++) {
          for (int f = j; f <= j + 1; f++) {
            if (matrix[k][f] == '.')
              p++;
            else {
              tx = k, ty = f;
            }
          }
        }
        if (p == 3) {
          node.x = tx, node.y = ty;
          q.push(node);
          matrix[tx][ty] = '.';
        }
      }
    }
  }
}
int main() {
  int n, m;
  int cnt = 0;
  memset(matrix, -1, sizeof matrix);
  scanf("%d %d", &n, &m);
  getchar();
  for (int i = 1; i <= n; i++) {
    matrix[i][0] = matrix[i][m + 1] = '*';
    for (int j = 1; j <= m; j++) {
      matrix[i][j] = getchar();
      if (matrix[i][j] == '.') {
        Node node(i, j);
        q.push(node);
      }
    }
    getchar();
  }
  for (int i = 0; i <= m + 1; i++) matrix[0][i] = matrix[n + 1][i] = '*';
  bfs();
  for (int i = 1; i <= n; i++) {
    matrix[i][0] = matrix[i][m + 1] = '*';
    for (int j = 1; j <= m; j++) {
      putchar(matrix[i][j]);
    }
    putchar('\n');
  }
}
