#include <bits/stdc++.h>
char* readInt(char* pC, int& res) {
  int r = 0;
  char c = 0;
  bool digit = false;
  while (c = *pC++) {
    if (c <= '9' && c >= '0') {
      digit = true;
      r = (r << 3) + (r << 1) + (c - '0');
    } else if (digit) {
      break;
    }
  }
  res = r;
  return pC;
}
int Y, X;
int** b;
bool checkPoint(int x, int y) {
  if (b[y][x] == 0) false;
  if (y > 0 && x > 0) {
    if (b[y - 1][x] == 0 && b[y - 1][x - 1] == 0 && b[y][x - 1] == 0)
      return true;
  }
  if (y > 0 && x < X - 1) {
    if (b[y - 1][x] == 0 && b[y - 1][x + 1] == 0 && b[y][x + 1] == 0)
      return true;
  }
  if (y < Y - 1 && x > 0) {
    if (b[y + 1][x] == 0 && b[y + 1][x - 1] == 0 && b[y][x - 1] == 0)
      return true;
  }
  if (y < Y - 1 && x < X - 1) {
    if (b[y + 1][x] == 0 && b[y + 1][x + 1] == 0 && b[y][x + 1] == 0)
      return true;
  }
  return false;
}
void checkAround(int x0, int y0, std::set<std::pair<int, int> >& s) {
  int sy = std::max(0, y0 - 1);
  int ey = std::min(Y - 1, y0 + 1);
  int sx = std::max(0, x0 - 1);
  int ex = std::min(X - 1, x0 + 1);
  for (int y = sy; y <= ey; ++y) {
    for (int x = sx; x <= ex; ++x) {
      if (b[y][x] == 1 && checkPoint(x, y)) {
        s.insert(std::pair<int, int>(y, x));
      }
    }
  }
}
int main() {
  char* s = new char[2005];
  char* pC = s;
  gets(s);
  pC = readInt(pC, Y);
  pC = readInt(pC, X);
  b = new int*[Y];
  for (int i = 0; i < Y; ++i) b[i] = new int[X];
  int n0 = 0;
  for (int i = 0; i < Y; ++i) {
    gets(s);
    for (int j = 0; j < X; ++j) {
      if (s[j] == '*') {
        b[i][j] = 1;
      } else {
        b[i][j] = 0;
        n0++;
      }
    }
  }
  if (n0 == 0) {
  } else {
    std::set<std::pair<int, int> > m1;
    std::set<std::pair<int, int> > m2;
    for (int y = 0; y < Y; ++y) {
      for (int x = 0; x < X; ++x) {
        if (checkPoint(x, y)) {
          m1.insert(std::pair<int, int>(y, x));
        }
      }
    }
    while (m1.size()) {
      std::set<std::pair<int, int> >::iterator itr = m1.begin();
      while (itr != m1.end()) {
        int y = itr->first;
        int x = itr->second;
        if (b[y][x] == 1) {
          b[y][x] = 0;
          checkAround(x, y, m2);
        }
        ++itr;
      }
      m2.swap(m1);
      m2.clear();
    }
  }
  for (int i = 0; i < Y; ++i) {
    for (int j = 0; j < X; ++j) {
      printf("%c", (b[i][j] == 1) ? '*' : '.');
    }
    printf("\n");
  }
  return 0;
}
