#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1 << 11;
char g[N][N], res[N][N];
int n, m;
bool valid(int x, int y) { return 0 <= x && x < n && 0 <= y && y < m; }
bool can(int x, int y) { return valid(x, y) && g[x][y] == '.'; }
bool check(int x, int y) {
  if (can(x, y)) return false;
  for (int a : {-1, +1}) {
    for (int b : {-1, +1}) {
      bool works = true;
      for (auto S = (1); S < (4); ++S)
        works &= can(x + a * (S & 1), y + b * (S >> 1 & 1));
      if (works) return true;
    }
  }
  return false;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  for (auto i = (0); i < (n); ++i)
    for (auto j = (0); j < (m); ++j) cin >> g[i][j];
  queue<pair<int, int>> q;
  for (auto i = (0); i < (n); ++i)
    for (auto j = (0); j < (m); ++j)
      if (check(i, j)) q.push({i, j});
  while (!q.empty()) {
    auto [x, y] = q.front();
    q.pop();
    if (!check(x, y)) continue;
    g[x][y] = '.';
    for (int i : {-1, 0, +1})
      for (int j : {-1, 0, +1}) q.push({x + i, y + j});
  }
  for (auto i = (0); i < (n); ++i) cout << g[i] << '\n';
}
