#include <bits/stdc++.h>
using namespace std;
const char C = '.';
int n, m;
vector<string> a;
queue<pair<int, int>> r;
bool used[5001][5001];
inline void find3(int i, int j) {
  int lastx = -1;
  int lasty = -1;
  int need = 0;
  for (int i1 = 0; i1 < 2; i1++)
    for (int j1 = 0; j1 < 2; j1++)
      if (a[i + i1][j + j1] != C) {
        need++;
        lastx = i + i1;
        lasty = j + j1;
      }
  if (need == 1) {
    used[i][j] = true;
    r.push(make_pair(lastx, lasty));
  }
}
inline void find(int x1, int x2, int y1, int y2) {
  for (int i = x1; i < x2; i++) {
    for (int j = y1; j < y2; j++) {
      if (!used[i][j]) find3(i, j);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    a.push_back(s);
  }
  find(0, n - 1, 0, m - 1);
  while (!r.empty()) {
    pair<int, int> q = r.front();
    r.pop();
    int x = q.first;
    int y = q.second;
    a[x][y] = C;
    find(max(0, x - 1), min(n - 1, x + 1), max(0, y - 1), min(m - 1, y + 1));
  }
  int ans = 0;
  for (int i = 0; i < n; i++) cout << a[i] << endl;
  return 0;
}
