#include <bits/stdc++.h>
using namespace std;
int mas[1001][1001];
char chars[1000][1001];
int n, m;
int st = 0;
vector<int> woi;
int p = 0;
void dfs(int x, int y) {
  st++;
  mas[x][y] = p;
  if (x != 0) {
    if (mas[x - 1][y] == 0 && chars[x - 1][y] == '.') {
      dfs(x - 1, y);
    }
  }
  if (y != 0) {
    if (mas[x][y - 1] == 0 && chars[x][y - 1] == '.') {
      dfs(x, y - 1);
    }
  }
  if (x + 1 != n) {
    if (mas[x + 1][y] == 0 && chars[x + 1][y] == '.') {
      dfs(x + 1, y);
    }
  }
  if (y + 1 != m + 1) {
    if (mas[x][y + 1] == 0 && chars[x][y + 1] == '.') {
      dfs(x, y + 1);
    }
  }
}
void startdfs(int x, int y) {
  st = 0;
  p++;
  dfs(x, y);
  woi.push_back(st);
}
int calculate(int x, int y) {
  int ans = 1;
  set<int> f;
  if (x != 0) {
    f.emplace(mas[x - 1][y]);
  }
  if (y != 0) {
    f.emplace(mas[x][y - 1]);
  }
  if (x != n) {
    f.emplace(mas[x + 1][y]);
  }
  if (y != m + 1) {
    f.emplace(mas[x][y + 1]);
  }
  for (auto w : f) {
    ans += woi[w];
  }
  return ans;
}
int main() {
  char ch;
  woi.push_back(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m + 1; j++) {
      scanf("%c", &ch);
      chars[i][j] = ch;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m + 1; j++) {
      if (chars[i][j] == '.' && mas[i][j] == 0) {
        startdfs(i, j);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m + 1; j++) {
      if (chars[i][j] == '*') {
        int c = calculate(i, j) % 10;
        chars[i][j] = c + '0';
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < m + 1; j++) {
      printf("%c", chars[i][j]);
    }
    printf("\n");
  }
  return 0;
}
