#include <bits/stdc++.h>
using namespace std;
char g[1010][1010];
int R, C, N, c[1010][1010], s[1010101],
    d[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int dfs(int x, int y) {
  if (x < 0 || x >= R || y < 0 || y >= C || c[x][y] || g[x][y] == '*') return 0;
  c[x][y] = N;
  int s = 1;
  for (int i = 0; i < 4; i++) s += dfs(x + d[i][0], y + d[i][1]);
  return s;
}
int main() {
  scanf("%d%d", &R, &C);
  for (int i = 0; i < R; i++) scanf(" %s", g[i]);
  for (int i = 0; i < R; i++)
    for (int j = 0; j < C; j++) s[++N] = dfs(i, j);
  for (int i = 0; i < R; i++) {
    for (int j = 0; j < C; j++)
      if (g[i][j] == '*') {
        set<int> a;
        for (int k = 0; k < 4; k++) a.insert(c[i + d[k][0]][j + d[k][1]]);
        int z = 1;
        for (auto x : a) z += s[x];
        g[i][j] = '0' + (z % 10);
      }
    printf("%s\n", g[i]);
  }
}
