#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
int n, m;
char a[N][N];
int col[N][N];
int cnt[N * N];
void clear() {
  memset(col, -1, sizeof col);
  memset(cnt, 0, sizeof cnt);
}
bool check(int i, int j) { return 0 <= i && i < n && 0 <= j && j < m; }
void dfs(int i, int j, int c) {
  col[i][j] = c;
  cnt[c]++;
  for (int k = 0; k < 4; k++) {
    int newi = i + dx[k];
    int newj = j + dy[k];
    if (check(newi, newj) && a[newi][newj] == '.' && col[newi][newj] == -1) {
      dfs(newi, newj, c);
    }
  }
}
void solve() {
  for (int i = 0; i < n; i++) {
    scanf(" %s\n", a[i]);
  }
  int C = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '.' && col[i][j] == -1) {
        dfs(i, j, C++);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '*') {
        set<int> cols;
        for (int k = 0; k < 4; k++) {
          int newi = i + dx[k];
          int newj = j + dy[k];
          if (check(newi, newj) && a[newi][newj] == '.') {
            cols.insert(col[newi][newj]);
          }
        }
        int cur = 0;
        for (int c : cols) {
          cur += cnt[c];
        }
        a[i][j] = char((cur + 1) % 10 + '0');
      }
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%s\n", a[i]);
  }
}
int main() {
  while (scanf("%d%d", &n, &m) == 2) {
    clear();
    solve();
  }
}
