#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-8;
vector<string> parse(string s, string c) {
  int len = c.length(), p = -len, np;
  vector<string> ans;
  do {
    np = s.find(c, p + len);
    ans.push_back(s.substr(p + len, np - p - len));
    p = np;
  } while (p != string::npos);
  return ans;
}
string in[2005];
int row, col;
bool needtochange(int i, int j) {
  if (((in[i - 1][j - 1] == '.') && (in[i - 1][j] == '.') &&
       (in[i][j - 1] == '.')) ||
      ((in[i - 1][j] == '.') && (in[i - 1][j + 1] == '.') &&
       (in[i][j + 1] == '.')) ||
      ((in[i][j - 1] == '.') && (in[i + 1][j - 1] == '.') &&
       (in[i + 1][j] == '.')) ||
      ((in[i + 1][j] == '.') && (in[i + 1][j + 1] == '.') &&
       (in[i][j + 1] == '.')))
    return true;
  return false;
}
int main() {
  cin >> row >> col;
  in[0] = string(col + 4, '$');
  in[row + 1] = in[0];
  for (int i = 1; i <= row; i++) {
    cin >> in[i];
    in[i] = "$" + in[i] + "$";
  }
  queue<pair<int, int> > Q;
  for (int i = 1; i <= row; i++)
    for (int j = 1; j <= col; j++)
      if ((in[i][j] == '*') && needtochange(i, j)) {
        Q.push(make_pair(i, j));
        in[i][j] = '.';
      }
  while (!Q.empty()) {
    pair<int, int> curr = Q.front();
    Q.pop();
    for (int dx = -1; dx <= 1; dx++)
      for (int dy = -1; dy <= 1; dy++) {
        int i = curr.first + dx;
        int j = curr.second + dy;
        if ((in[i][j] == '*') && needtochange(i, j)) {
          Q.push(make_pair(i, j));
          in[i][j] = '.';
        }
      }
  }
  for (int i = 1; i <= row; i++, cout << endl)
    for (int j = 1; j <= col; j++) cout << in[i][j];
  return 0;
}
