#include <bits/stdc++.h>
using namespace std;
int main() {
  char map[55][55];
  int n, m;
  scanf("%d %d", &n, &m);
  memset(map, '0', sizeof(map));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cin >> map[i][j];
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (map[i][j] == '.') {
        while (map[i][j - 1] == '#') {
          ans++;
          break;
        }
        while (map[i - 1][j - 1] == '#') {
          ans++;
          break;
        }
        while (map[i - 1][j] == '#') {
          ans++;
          break;
        }
        while (map[i - 1][j + 1] == '#') {
          ans++;
          break;
        }
        while (map[i][j + 1] == '#') {
          ans++;
          break;
        }
        while (map[i + 1][j + 1] == '#') {
          ans++;
          break;
        }
        while (map[i + 1][j] == '#') {
          ans++;
          break;
        }
        while (map[i + 1][j - 1] == '#') {
          ans++;
          break;
        }
        map[i][j] = ans + '0';
        ans = 0;
      } else
        continue;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%c ", map[i][j]);
    }
    printf("\n");
  }
  return 0;
}
