#include <bits/stdc++.h>
using namespace std;
inline int d_compare(double x, double y) {
  return (fabs(x - y) <= 1e-8) ? 0 : (x > y) ? 1 : -1;
}
inline int mod(long long x, int y) {
  if (y == 0) return x;
  if (x < 0) x = -x;
  if (x >= y) x %= y;
  return x;
}
inline int cmod(int x, int y) {
  if (y == 0) return x;
  if (x < 0) x += (abs(x) / y + 1) * y;
  if (x >= y) x = x % y;
  return x;
}
int Bcount(int mask) {
  int n = 0;
  while (mask) n += ((mask & -mask) != 0), mask &= ~(mask & -mask);
  return n;
}
inline bool Bstate(int mask, int idx) { return (mask & (1 << idx)); }
inline int B1(int mask, int idx) { return mask | (1 << idx); }
inline int B0(int mask, int idx) { return mask & ~(1 << idx); }
inline int drift(int mask, int n) { return mask & ((1 << n) - 1); }
void debugmask(int mask, int n) {
  for (int i = 0; i < n; i++) cout << Bstate(mask, i);
}
class point {
 public:
  int x, y;
  point(int i, int j) {
    x = i;
    y = j;
  }
};
bool arr[2002][2002];
int n, m;
bool check(point wall) {
  if (arr[wall.x + 1][wall.y] && arr[wall.x][wall.y + 1] &&
      arr[wall.x + 1][wall.y + 1])
    return 1;
  if (arr[wall.x - 1][wall.y] && arr[wall.x][wall.y - 1] &&
      arr[wall.x - 1][wall.y - 1])
    return 1;
  if (arr[wall.x + 1][wall.y] && arr[wall.x][wall.y - 1] &&
      arr[wall.x + 1][wall.y - 1])
    return 1;
  if (arr[wall.x - 1][wall.y] && arr[wall.x][wall.y + 1] &&
      arr[wall.x - 1][wall.y + 1])
    return 1;
  return 0;
}
void dfs(point wall) {
  if (wall.x > n || wall.y > m) return;
  arr[wall.x][wall.y] = 1;
  if (!arr[wall.x - 1][wall.y] && check(point(wall.x - 1, wall.y)))
    dfs(point(wall.x - 1, wall.y));
  if (!arr[wall.x + 1][wall.y] && check(point(wall.x + 1, wall.y)))
    dfs(point(wall.x + 1, wall.y));
  if (!arr[wall.x][wall.y - 1] && check(point(wall.x, wall.y - 1)))
    dfs(point(wall.x, wall.y - 1));
  if (!arr[wall.x][wall.y + 1] && check(point(wall.x, wall.y + 1)))
    dfs(point(wall.x, wall.y + 1));
  if (!arr[wall.x - 1][wall.y + 1] && check(point(wall.x - 1, wall.y + 1)))
    dfs(point(wall.x - 1, wall.y + 1));
  if (!arr[wall.x + 1][wall.y - 1] && check(point(wall.x + 1, wall.y - 1)))
    dfs(point(wall.x + 1, wall.y - 1));
  if (!arr[wall.x - 1][wall.y - 1] && check(point(wall.x - 1, wall.y - 1)))
    dfs(point(wall.x - 1, wall.y - 1));
  if (!arr[wall.x + 1][wall.y + 1] && check(point(wall.x + 1, wall.y + 1)))
    dfs(point(wall.x + 1, wall.y + 1));
}
void input() {
  memset(arr, 0, sizeof arr);
  char c;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> c;
      arr[i][j] = (c == '.');
    }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  input();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (!arr[i][j] && check(point(i, j))) dfs(point(i, j));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      if (arr[i][j])
        cout << '.';
      else
        cout << '*';
    cout << endl;
  }
  cout << endl;
  return 0;
}
