#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W, cnt1 = 0, cnt2 = 0;
  string len1, tmp;
  cin >> H >> W;
  for (int i = 0; i < W; i++) {
    cin >> tmp;
    len1 += tmp;
  }
  for (int i = 0; i < H * W; i++) {
    int k = 0;
    if (len1.at(i) == '#') {
      cnt1 = 0;
      cnt2 = 0;
      cout << '#';
      continue;
    }
    k = -7;
    if (i + k >= 0 && len1.at(i + k) == '#') cnt1++;
    k = -6;
    if (i + k >= 0 && len1.at(i + k) == '#') cnt1++;
    k = -5;
    if (i + k >= 0 && len1.at(i + k) == '#') cnt1++;
    k = -1;
    if (i + k >= 0 && len1.at(i + k) == '#') cnt1++;
    k = 1;
    if (i + k >= 0 && len1.at(i + k) == '#') cnt1++;
    k = 5;
    if (i + k >= 0 && len1.at(i + k) == '#') cnt1++;
    k = 6;
    if (i + k >= 0 && len1.at(i + k) == '#') cnt1++;
    k = 7;
    if (i + k >= 0 && len1.at(i + k) == '#') cnt1++;
    cout << cnt1 << endl;
    k = 0;
    cnt1 = 0;
    cnt2++;
    if (cnt2 == W) {
      cnt2 = 0;
      cout << endl;
    }
  }
}
