#include <bits/stdc++.h>
using namespace std;
using LLint = long long int;
const int mod = 1000000007;
int main() {
  int H, W;
  string S[60];
  cin >> H >> W;
  for (int i = 0; i < H; ++i) cin >> S[i];
  int x[] = {1, 1, 0, -1, -1, -1, 0, 1};
  int y[] = {0, -1, -1, -1, 0, 1, 1, 1};
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (S[i][j] != '#') {
        int count = 0;
        for (int k = 0; k < 8; ++k) {
          int dy = i + y[k];
          int dx = j + x[k];
          if (dy < 0 && dy >= H) continue;
          if (dx < 0 && dx >= W) continue;
          if (S[dy][dx] == '#') {
            ++count;
          }
        }
        S[i][j] = char(count - 'a');
      }
    }
  }
  for (int i = 0; i < H; ++i) cout << S[i] << endl;
  return 0;
}
