You are given a rectangular field of n × m cells. Each cell is either empty or impassable (contains an obstacle). Empty cells are marked with '.', impassable cells are marked with '*'. Let's call two empty cells adjacent if they share a side.

Let's call a connected component any non-extendible set of cells such that any two of them are connected by the path of adjacent cells. It is a typical well-known definition of a connected component.

For each impassable cell (x, y) imagine that it is an empty cell (all other cells remain unchanged) and find the size (the number of cells) of the connected component which contains (x, y). You should do it for each impassable cell independently.

The answer should be printed as a matrix with n rows and m columns. The j-th symbol of the i-th row should be "." if the cell is empty at the start. Otherwise the j-th symbol of the i-th row should contain the only digit —- the answer modulo 10. The matrix should be printed without any spaces.

To make your output faster it is recommended to build the output as an array of n strings having length m and print it as a sequence of lines. It will be much faster than writing character-by-character.

As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use scanf/printf instead of cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.

Input

The first line contains two integers n, m (1 ≤ n, m ≤ 1000) — the number of rows and columns in the field.

Each of the next n lines contains m symbols: "." for empty cells, "*" for impassable cells.

Output

Print the answer as a matrix as described above. See the examples to precise the format of the output.

Examples

Input

3 3
*.*
.*.
*.*


Output

3.3
.5.
3.3


Input

4 5
**..*
..***
.*.*.
*.*.*


Output

46..3
..732
.6.4.
5.4.3

Note

In first example, if we imagine that the central cell is empty then it will be included to component of size 5 (cross). If any of the corner cell will be empty then it will be included to component of size 3 (corner).
#include <bits/stdc++.h>
const int dx[] = {0, 0, -1, 1}, dy[] = {-1, 1, 0, 0};
using namespace std;
long long Gcd(long long a, long long b) {
  if (a % b == 0) return b;
  return Gcd(b, a % b);
}
long long Max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long Min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
long long findlcm(vector<long long> arr, long long n) {
  long long ans = arr[0];
  for (int i = 1; i < n; i++) ans = (((arr[i] * ans)) / (Gcd(arr[i], ans)));
  return ans;
}
long long gcdExtended(long long a, long long b, long long *x, long long *y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long x1, y1;
  long long gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long modInverse(long long a, long long m) {
  long long x, y;
  long long g = gcdExtended(a, m, &x, &y);
  if (g != 1)
    return -1;
  else {
    long long res = (x % m + m) % m;
    return res;
  }
}
vector<long long> primeFactors(long long n) {
  vector<long long> v;
  while (n % 2 == 0) {
    v.push_back(2);
    n = n / 2;
  }
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      v.push_back(i);
      n = n / i;
    }
  }
  if (n > 2) v.push_back(n);
  return v;
}
long long C[2001][2000];
void binomialCoeff(long long n, long long k) {
  long long i, j;
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= k; j++) {
      if (j == 0 || j == i)
        C[i][j] = 1;
      else
        C[i][j] = (C[i - 1][j - 1] % 1000000007 + C[i - 1][j] % 1000000007) %
                  1000000007;
    }
  }
}
long long spf[100010];
void sieve() {
  spf[1] = 1;
  for (int i = 2; i < 100010; i++) spf[i] = i;
  for (int i = 4; i < 100010; i += 2) spf[i] = 2;
  for (int i = 3; i * i < 100010; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j < 100010; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
long long binarySearch(long long arr[], long long l, long long r, long long x) {
  if (r >= l) {
    long long mid = l + (r - l) / 2;
    if (arr[mid] == x) return mid;
    if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x);
    return binarySearch(arr, mid + 1, r, x);
  }
  return -1;
}
const long long N = 100000;
long long n;
long long tree[2 * N];
void build(long long arr[]) {
  for (long long i = 0; i < n; i++) {
    tree[n + i] = arr[i];
  }
  for (long long i = n - 1; i > 0; --i) {
    tree[i] = tree[i << 1] + tree[i << 1 | 1];
  }
}
void updateTreeNode(long long p, long long value) {
  tree[p + n] = value;
  p = p + n;
  for (long long i = p; i > 1; i >>= 1) {
    tree[i >> 1] = tree[i] + tree[i ^ 1];
  }
}
long long query(long long l, long long r) {
  long long res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) {
      res += tree[l++];
    }
    if (r & 1) {
      res += tree[--r];
    }
  }
  return res;
}
vector<long long> shortPath(vector<pair<long long, long long> > v[],
                            long long src, long long V = 0) {
  set<pair<long long, long long> > setds;
  long long sizee = V;
  long long IN = 0x3f3f3f3f;
  vector<long long> dist(sizee, IN);
  setds.insert(make_pair(0, src));
  dist[src] = 0;
  while (!setds.empty()) {
    pair<long long, long long> tmp = *(setds.begin());
    setds.erase(setds.begin());
    long long u = tmp.second;
    vector<pair<long long, long long> >::iterator i;
    for (i = v[u].begin(); i != v[u].end(); ++i) {
      long long v = (*i).first;
      long long weight = (*i).second;
      if (dist[v] > dist[u] + weight) {
        if (dist[v] != 0x3f3f3f3f)
          setds.erase(setds.find(make_pair(dist[v], v)));
        dist[v] = dist[u] + weight;
        setds.insert(make_pair(dist[v], v));
      }
    }
  }
  return dist;
}
char mat[1001][1001];
bool visited[1001][1001];
bool visited1[1001][1001];
pair<long long, long long> pa[1001][1001];
long long rec[1001][1001];
long long m;
long long valid(long long x, long long y) {
  if (x == n || y == m || visited[x][y] == true || mat[x][y] == '*' ||
      x == -1 || y == -1)
    return 0;
  return 1;
}
long long valid1(long long x, long long y) {
  if (x == n || y == m || visited1[x][y] == true || mat[x][y] == '*' ||
      x == -1 || y == -1)
    return 0;
  return 1;
}
long long vali(long long x, long long y) {
  if (x == n || x == -1 || y == m || y == -1 || mat[x][y] == '*') return 0;
  return 1;
}
void dfs(pair<long long, long long> cur1, pair<long long, long long> par1) {
  visited[cur1.first][cur1.second] = true;
  rec[par1.first][par1.second]++;
  pa[cur1.first][cur1.second] = make_pair(par1.first, par1.second);
  for (long long i = 0; i < 4; i++) {
    long long x = dx[i] + cur1.first;
    long long y = dy[i] + cur1.second;
    if (valid(x, y)) {
      dfs(make_pair(x, y), par1);
    }
  }
  return;
}
void dfs1(pair<long long, long long> cur1, pair<long long, long long> par1) {
  visited1[cur1.first][cur1.second] = true;
  rec[cur1.first][cur1.second] = rec[par1.first][par1.second];
  for (long long i = 0; i < 4; i++) {
    long long x = dx[i] + cur1.first;
    long long y = dy[i] + cur1.second;
    if (valid1(x, y)) {
      dfs1(make_pair(x, y), par1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0, _n = (n); i < _n; i++) {
    for (int j = 0, _n = (m); j < _n; j++) {
      cin >> mat[i][j];
    }
  }
  for (int i = 0, _n = (n); i < _n; i++) {
    for (int j = 0, _n = (m); j < _n; j++) {
      if (mat[i][j] == '.') {
        if (valid(i, j)) {
          dfs(make_pair(i, j), make_pair(i, j));
          dfs1(make_pair(i, j), make_pair(i, j));
        }
      }
    }
  }
  for (int i = 0, _n = (n); i < _n; i++) {
    for (int j = 0, _n = (m); j < _n; j++) {
      if (mat[i][j] == '*') {
        long long c = 1;
        map<pair<long long, long long>, long long> ma;
        for (long long k = 0; k < 4; k++) {
          long long xx = dx[k] + i;
          long long yy = dy[k] + j;
          if (vali(xx, yy)) {
            ma[pa[xx][yy]]++;
            if (ma[pa[xx][yy]] == 1) c += rec[xx][yy];
          }
        }
        c = c % 10;
        cout << c;
      } else {
        cout << ".";
      }
    }
    cout << endl;
  }
}
