#include <bits/stdc++.h>
using namespace std;
ifstream f;
ofstream of;
int **room;
bool isOneStarInSq(pair<int, int> pos);
int main() {
  int n, m;
  int border = 2;
  scanf("%d %d", &n, &m);
  room = new int *[n + 2 * border];
  for (int i = 0; i < n + 2 * border; i++) {
    room[i] = new int[m + 2 * border];
    for (int j = 0; j < m + 2 * border; j++) {
      room[i][j] = 1;
    }
  }
  queue<pair<int, int> > aloneStars;
  pair<int, int> *stars = new pair<int, int>[n * m];
  int amount = 0;
  for (int i = border; i < n + border; i++) {
    char a;
    scanf("%c", &a);
    for (int j = border; j < m + border; j++) {
      scanf("%c", &a);
      if (a == '.') {
        room[i][j] = 0;
      } else {
        stars[amount++] = (make_pair(i, j));
      }
    }
  }
  for (int i = 0; i < amount; i++) {
    if (isOneStarInSq(stars[i])) {
      aloneStars.push(stars[i]);
    }
  }
  while (!aloneStars.empty()) {
    pair<int, int> posStar = aloneStars.front();
    aloneStars.pop();
    if (room[posStar.first][posStar.second] == 0) continue;
    room[posStar.first][posStar.second] = 0;
    int x = posStar.first, y = posStar.second;
    for (int i = x - 1; i <= x + 1; i++) {
      for (int j = y - 1; j <= y + 1; j++) {
        if (room[i][j] == 1 && isOneStarInSq(make_pair(i, j))) {
          aloneStars.push(make_pair(i, j));
        }
      }
    }
  }
  for (int i = border; i < n + border; i++) {
    for (int j = border; j < m + border; j++) {
      if (room[i][j] == 0)
        printf("%c", '.');
      else
        printf("%c", '*');
    }
    printf("%c", '\n');
  }
  return 0;
}
bool isOneStarInSq(pair<int, int> pos) {
  int count = 0;
  int x = pos.first;
  int y = pos.second;
  if (room[x - 1][y - 1] == 1) count++;
  if (room[x][y - 1] == 1) count++;
  if (room[x - 1][y] == 1) count++;
  if (count == 0) {
    return true;
  }
  count = 0;
  if (room[x - 1][y + 1] == 1) count++;
  if (room[x][y + 1] == 1) count++;
  if (room[x - 1][y] == 1) count++;
  if (count == 0) {
    return true;
  }
  count = 0;
  if (room[x + 1][y - 1] == 1) count++;
  if (room[x][y - 1] == 1) count++;
  if (room[x + 1][y] == 1) count++;
  if (count == 0) {
    return true;
  }
  count = 0;
  if (room[x + 1][y + 1] == 1) count++;
  if (room[x][y + 1] == 1) count++;
  if (room[x + 1][y] == 1) count++;
  if (count == 0) {
    return true;
  }
  return false;
}
