#include <bits/stdc++.h>
using namespace std;
class square {
 private:
  int m, n, sum;
  vector<char> s;
  int a[2500];

 public:
  square(int a, int b) {
    m = a;
    n = b;
    sum = a * b;
  }
  void input() {
    char temp;
    int i;
    for (i = 0; i < sum; ++i) {
      cin >> temp;
      if (temp == '\n') {
        --i;
      }
      if (temp != '\n') s.push_back(temp);
    }
  }
  void output() {
    int i = 0;
    for (i = 0; i < sum; ++i) {
      cout << s[i];
      if ((i + 1) % n == 0) {
        cout << endl;
      }
    }
  }
  void Minesweeper() {
    int i, k, h = 0;
    input();
    for (i = 0; i < sum; ++i) {
      if (s[i] == '.')
        while (true) {
          k = 0;
          if (s[i - 1] == '#' && i >= 1) {
            ++k;
          }
          if (s[i + 1] == '#') {
            ++k;
          }
          if (s[i - n] == '#' && i >= n) {
            ++k;
          }
          if (s[i + n] == '#' && i <= sum - 1) {
            ++k;
          }
          if (s[i - n - 1] == '#' && i >= n - 1) {
            ++k;
          }
          if (s[i - n + 1] == '#' && i >= n + 1) {
            ++k;
          }
          if (s[i + n - 1] == '#' && i < sum - n) {
            ++k;
          }
          if (s[i + n + 1] == '#' && i < sum - n) {
            ++k;
          }
          s[i] = 'k';
        }
    }
    output();
  }
};
int main() {
  int m, n;
  cin >> m;
  cin >> n;
  square a(m, n);
  a.Minesweeper();
  return 0;
}
