#include <bits/stdc++.h>
using namespace std;
int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  int h, w;
  string s;
  vector<string> vect(50);
  cin >> h >> w;
  for (int i = (int)0; i < (int)h; i++) {
    cin >> vect.at(i);
  }
  char ans[50][50];
  for (int i = (int)0; i < (int)h; i++) {
    for (int j = (int)0; j < (int)w; j++) {
      ans[i][j] = '0';
    }
  }
  for (int i = (int)0; i < (int)h; i++) {
    for (int j = (int)0; j < (int)w; j++) {
      if (vect[i][j] == '#') {
        ans[i][j] = '#';
        if (ans[i - 1][j - 1] != '#')
          ans[i - 1][j - 1] = char(int(ans[i - 1][j - 1]) + 1);
        if (ans[i - 1][j] != '#') ans[i - 1][j] = char(int(ans[i - 1][j]) + 1);
        if (ans[i - 1][j + 1] != '#')
          ans[i - 1][j + 1] = char(int(ans[i - 1][j + 1]) + 1);
        if (ans[i][j - 1] != '#') ans[i][j - 1] = char(int(ans[i][j - 1]) + 1);
        if (ans[i + 1][j] != '#') ans[i + 1][j] = char(int(ans[i + 1][j]) + 1);
        if (ans[i + 1][j - 1] != '#')
          ans[i + 1][j - 1] = char(int(ans[i + 1][j - 1]) + 1);
        if (ans[i + 1][j + 1] != '#')
          ans[i + 1][j + 1] = char(int(ans[i + 1][j + 1]) + 1);
        if (ans[i][j + 1] != '#') ans[i][j + 1] = char(int(ans[i][j + 1]) + 1);
      }
    }
  }
  for (int i = (int)0; i < (int)h; i++) {
    for (int j = (int)0; j < (int)w; j++) {
      cout << ans[i][j];
    }
    cout << endl;
  }
  return 0;
}
