#include <bits/stdc++.h>
using namespace std;
char a[1050][1050];
struct BOOK {
  int num;
  int count;
} book[1050][1050];
bool ju[1000005];
int tx[4] = {1, 0, 0, -1};
int ty[4] = {0, 1, -1, 0};
struct point {
  point(int xx, int yy) {
    x = xx;
    y = yy;
  }
  int x, y;
};
queue<point> q;
stack<point> qcolor;
int main() {
  int n, m, cnt = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", a[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (!book[i][j].count && a[i][j] == '.') {
        book[i][j].count = ++cnt;
        q.push(point(i, j));
        while (q.size()) {
          qcolor.push(q.front());
          point p = q.front();
          q.pop();
          for (int k = 0; k < 4; k++) {
            int dx = p.x + tx[k];
            int dy = p.y + ty[k];
            if (dx > -1 && dx < n && dy > -1 && dy < m && !book[dx][dy].count &&
                (a[dx][dy] == a[p.x][p.y]))
              q.push(point(dx, dy)), book[dx][dy].count = cnt;
          }
        }
        int step = qcolor.size();
        while (qcolor.size()) {
          point p = qcolor.top();
          qcolor.pop();
          book[p.x][p.y].num = step;
        }
      }
    }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '*') {
        book[i][j].num = 1;
        for (int k = 0; k < 4; k++) {
          int dx = i + tx[k];
          int dy = j + ty[k];
          if (dx > -1 && dx < n && dy > -1 && dy < m && a[dx][dy] == '.' &&
              !ju[book[dx][dy].count]) {
            book[i][j].num += book[dx][dy].num;
            book[i][j].num %= 10;
            ju[book[dx][dy].count] = 1;
          }
        }
        for (int k = 0; k < 4; k++) {
          int dx = i + tx[k];
          int dy = j + ty[k];
          ju[book[dx][dy].count] = 0;
        }
        a[i][j] = '0' + book[i][j].num;
        putchar(a[i][j]);
      } else
        putchar('.');
    }
    putchar('\n');
  }
  return 0;
}
