#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;
template <typename T = vii>
using vec = vector<T>;
const ll INF = 1e18, MOD = 1e9 + 7;
const int MAX = 2e3 + 5;
bool mat[MAX][MAX];
bool used[MAX][MAX];
inline bool check(const int i, const int j) {
  if (not mat[i][j]) return false;
  for (const int di : {-1, 1}) {
    for (const int dj : {-1, 1}) {
      int res = 0;
      for (const int x : {i, i + di}) {
        for (const int y : {j, j + dj}) {
          res += mat[x][y];
        }
      }
      if (res == 1) return true;
    }
  }
  return false;
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  memset(mat, true, sizeof mat);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      mat[i + 1][j + 1] = s[j] == '*';
    }
  }
  queue<pii> q;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (check(i, j)) {
        q.emplace(i, j);
      }
    }
  }
  while (not q.empty()) {
    auto [i, j] = q.front();
    q.pop();
    mat[i][j] = 0;
    used[i][j] = true;
    for (int x = max(1, i - 1); x <= min(n, i + 1); x++) {
      for (int y = max(1, j - 1); y <= min(m, j + 1); y++) {
        if (not used[x][y] and check(x, y)) {
          q.emplace(x, y);
          used[x][y] = true;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << (mat[i][j] ? '*' : '.');
    }
    cout << '\n';
  }
}
