#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const double EXP = 2.7182818284590452;
const double Pi = 3.14159265;
const double EPS = 1e-11;
const int INF = 1000 * 1000 * 1000;
const long long INFL = INF * 1000 * 100;
char arr[2003][2003], c;
bool was[2003][2003];
int n, m;
queue<std::pair<int, int> > stars;
std::pair<int, int> cur;
std::pair<int, int> mask[] = {std::make_pair(-1, -1), std::make_pair(-1, 0),
                              std::make_pair(-1, 1),  std::make_pair(0, -1),
                              std::make_pair(0, 1),   std::make_pair(1, -1),
                              std::make_pair(1, 0),   std::make_pair(1, 1)};
bool IsValid(int r, int c) {
  if (r < 1 || r > n) return false;
  if (c < 1 || c > m) return false;
  return true;
}
bool Check(int r, int c) {
  if (arr[r][c - 1] == arr[r - 1][c - 1] &&
      arr[r - 1][c - 1] == arr[r - 1][c] && arr[r - 1][c] == '.')
    return true;
  if (arr[r - 1][c] == arr[r - 1][c + 1] &&
      arr[r - 1][c + 1] == arr[r][c + 1] && arr[r][c + 1] == '.')
    return true;
  if (arr[r][c + 1] == arr[r + 1][c + 1] &&
      arr[r + 1][c + 1] == arr[r + 1][c] && arr[r + 1][c] == '.')
    return true;
  if (arr[r + 1][c] == arr[r + 1][c - 1] &&
      arr[r + 1][c - 1] == arr[r][c - 1] && arr[r][c - 1] == '.')
    return true;
  return false;
}
void AddNew(int r, int c) {
  int rr, cc;
  for (int i = (0); i < (8); ++i) {
    rr = r + mask[i].first;
    cc = c + mask[i].second;
    if (IsValid(rr, cc) && arr[rr][cc] == '*') {
      if (!was[rr][cc] && Check(rr, cc)) {
        stars.push(std::make_pair(rr, cc));
        was[rr][cc] = true;
      }
    }
  }
}
int main(void) {
  cin >> n >> m;
  for (int i = (0); i < (n + 2); ++i)
    for (int j = (0); j < (m + 2); ++j) arr[i][j] = '*';
  for (int i = (1); i < (n + 1); ++i) {
    scanf("%c", &c);
    for (int j = (1); j < (m + 1); ++j) scanf("%c", arr[i] + j);
  }
  for (int i = (1); i < (n + 1); ++i)
    for (int j = (1); j < (m + 1); ++j) {
      if (Check(i, j)) {
        stars.push(std::make_pair(i, j));
        was[i][j] = true;
      }
    }
  while (stars.size()) {
    cur = stars.front();
    stars.pop();
    arr[cur.first][cur.second] = '.';
    AddNew(cur.first, cur.second);
  }
  for (int i = (1); i < (n + 1); ++i) {
    for (int j = (1); j < (m + 1); ++j) {
      printf("%c", arr[i][j]);
    }
    printf("\n");
  }
  return 0;
}
