#include <bits/stdc++.h>
using namespace std;
int n, m;
int used = 0;
vector<vector<int>> colors;
vector<string> field;
vector<int> values;
void dfs(pair<int, int> root, int color) {
  ++used;
  int x = root.first;
  int y = root.second;
  colors[y][x] = color;
  if (x != 0 && colors[y][x - 1] != color && field[y][x - 1] != '*')
    dfs(make_pair(x - 1, y), color);
  if (x != m - 1 && colors[y][x + 1] != color && field[y][x + 1] != '*')
    dfs(make_pair(x + 1, y), color);
  if (y != 0 && colors[y - 1][x] != color && field[y - 1][x] != '*')
    dfs(make_pair(x, y - 1), color);
  if (y != n - 1 && colors[y + 1][x] != color && field[y + 1][x] != '*')
    dfs(make_pair(x, y + 1), color);
}
bool in(int color, vector<int>& v) {
  for (int i = 0; i < (int)v.size(); ++i) {
    if (v[i] == color) return true;
  }
  return false;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cin >> n >> m;
  field.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> field[i];
  }
  string s;
  colors.resize(n);
  for (int i = 0; i < n; ++i) {
    colors[i].resize(m, 0);
  }
  int cnt = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (field[i][j] != '*' && colors[i][j] == 0) {
        used = 0;
        dfs(make_pair(j, i), cnt);
        values.push_back(used);
        ++cnt;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (colors[i][j] == 0) {
        int res = 0;
        vector<int> used_colors;
        if (i != 0 && colors[i - 1][j] != 0) {
          res += values[colors[i - 1][j] - 1];
          used_colors.push_back(colors[i - 1][j] - 1);
        }
        if (i != n - 1 && colors[i + 1][j] != 0 &&
            !in(colors[i + 1][j] - 1, used_colors)) {
          res += values[colors[i + 1][j] - 1];
          used_colors.push_back(colors[i + 1][j] - 1);
        }
        if (j != 0 && colors[i][j - 1] != 0 &&
            !in(colors[i][j - 1] - 1, used_colors)) {
          res += values[colors[i][j - 1] - 1];
          used_colors.push_back(colors[i][j - 1] - 1);
        }
        if (j != m - 1 && colors[i][j + 1] != 0 &&
            !in(colors[i][j + 1] - 1, used_colors)) {
          res += values[colors[i][j + 1] - 1];
        }
        field[i][j] = (res + 1) % 10 + '0';
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cout << field[i][j];
    }
    cout << endl;
  }
  return 0;
}
