#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T SQR(T x) {
  return x * x;
}
template <class T>
T MIN(T x, T y) {
  return (x < y) ? x : y;
}
template <class T>
T MAX(T x, T y) {
  return (x > y) ? x : y;
}
template <class T>
void UPDATE_MIN(T &x, T y) {
  if (y < x) {
    x = y;
  }
}
template <class T>
void UPDATE_MAX(T &x, T y) {
  if (x < y) {
    x = y;
  }
}
template <class T>
inline string TOSTR(const T &x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
long long powmod(long long a, long long p, long long m) {
  long long r = 1;
  while (p) {
    if (p & 1) r = r * a % m;
    p >>= 1;
    a = a * a % m;
  }
  return r;
}
template <typename K, typename V>
V GetWithDef(const std::unordered_map<K, V> &m, const K &key, const V &defval) {
  auto it = m.find(key);
  return (it == m.end()) ? defval : it->second;
}
template <typename K, typename V>
void SetDef(std::unordered_map<K, V> &m, const K &key, const V &defval) {
  auto it = m.find(key);
  if (it == m.end()) m[key] = defval;
}
struct pairhash {
  template <typename T, typename U>
  std::size_t operator()(const std::pair<T, U> &x) const {
    return std::hash<T>()(x.first | (x.second << 16));
  }
};
const int MOD = 1000 * 1000 * 1000 + 7;
const double PI = 3.1415926535897932384626433832795l;
int YS, XS;
char flat[2123][2123] = {};
int xmin, ymin, xmax, ymax;
int prev_ymin, prev_ymax, prev_xmin, prev_xmax;
int visited[2001][2001] = {};
void fill(int x1, int x2, int y1, int y2) {
  int l = 0, r = 0, u = 0, d = 0;
  UPDATE_MIN(xmin, x1);
  UPDATE_MIN(ymin, y1);
  UPDATE_MAX(xmax, x2);
  UPDATE_MAX(ymax, y2);
  int x, y;
  x = xmin;
  if (x1 == x && x > 0) {
    for (__typeof(y2 + 1) __tmpvar__start114 = (y1),
                          __tmpvar__end114 = (y2 + 1), y = __tmpvar__start114;
         y < __tmpvar__end114; y++) {
      if (flat[y][x - 1] == '.') {
        l = 1;
        break;
      }
    }
  }
  x = xmax;
  if (x2 == x && x < XS - 1) {
    for (__typeof(y2 + 1) __tmpvar__start123 = (y1),
                          __tmpvar__end123 = (y2 + 1), y = __tmpvar__start123;
         y < __tmpvar__end123; y++) {
      if (flat[y][x + 1] == '.') {
        r = 1;
        break;
      }
    }
  }
  y = ymin;
  if (y1 == y && y > 0) {
    for (__typeof(x2 + 1) __tmpvar__start132 = (x1),
                          __tmpvar__end132 = (x2 + 1), x = __tmpvar__start132;
         x < __tmpvar__end132; x++) {
      if (flat[y - 1][x] == '.') {
        u = 1;
        break;
      }
    }
  }
  y = ymax;
  if (y2 == y && y < YS - 1) {
    for (__typeof(x2 + 1) __tmpvar__start141 = (x1),
                          __tmpvar__end141 = (x2 + 1), x = __tmpvar__start141;
         x < __tmpvar__end141; x++) {
      if (flat[y + 1][x] == '.') {
        d = 1;
        break;
      }
    }
  }
  for (__typeof(y2 + 1) __tmpvar__start148 = (y1), __tmpvar__end148 = (y2 + 1),
                        y = __tmpvar__start148;
       y < __tmpvar__end148; y++) {
    for (__typeof(x2 + 1) __tmpvar__start149 = (x1),
                          __tmpvar__end149 = (x2 + 1), x = __tmpvar__start149;
         x < __tmpvar__end149; x++) {
      visited[y][x] = 1;
      flat[y][x] = '.';
    }
  }
  if (l && xmin == x1) fill(x1 - 1, x1 - 1, ymin, ymax);
  if (r && xmax == x2) fill(x2 + 1, x2 + 1, ymin, ymax);
  if (u && ymin == y1) fill(xmin, xmax, y1 - 1, y1 - 1);
  if (d && ymax == y2) fill(xmin, xmax, y2 + 1, y2 + 1);
}
int main() {
  scanf("%d%d\n", &YS, &XS);
  for (__typeof(YS) __tmpvar__start161 = (0), __tmpvar__end161 = (YS),
                    y = __tmpvar__start161;
       y < __tmpvar__end161; y++) {
    gets(flat[y]);
  }
  for (__typeof(YS) __tmpvar__start162 = (0), __tmpvar__end162 = (YS),
                    y = __tmpvar__start162;
       y < __tmpvar__end162; y++) {
    for (__typeof(XS) __tmpvar__start163 = (0), __tmpvar__end163 = (XS),
                      x = __tmpvar__start163;
         x < __tmpvar__end163; x++) {
      if (flat[y][x] == '.') {
        if (!visited[y][x]) {
          xmin = xmax = x;
          ymin = ymax = y;
          fill(xmin, xmax, ymin, ymax);
        }
      }
    }
  }
  for (__typeof(YS) __tmpvar__start173 = (0), __tmpvar__end173 = (YS),
                    y = __tmpvar__start173;
       y < __tmpvar__end173; y++) {
    puts(flat[y]);
  }
  return 0;
}
