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).

import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author hitarthk
 */
public class Edu5_3 {

    public static void main(String[] args) {
        FasterScanner in = new FasterScanner();
        int n = in.nextInt();
        int m = in.nextInt();
        char[][] a = new char[n + 2][m + 2];
        for (int i = 1; i <= n; i++) {
            a[i] = (" " + in.nextLine() + " ").toCharArray();
        }
        int[] dx = {0, 1, 0, -1};
        int[] dy = {1, 0, -1, 0};
        UF uf = new UF((n + 2) * (m + 2));
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (a[i][j] == '.') {
                    for (int k = 0; k < 4; k++) {
                        int r = i + dx[k];
                        int c = j + dy[k];
                        if (a[r][c] == '.') {
                            uf.union(r * (m + 2) + c, i * (m + 2) + j);
                        }
                    }
                }
            }
        }
//        System.out.println(Arrays.deepToString(a));
//        for(int i=1;i<=n;i++){
//            for(int j=1;j<=m;j++){
//                System.out.println(i+" "+j+" "+uf.size[uf.find(i*(m+2)+j)]);
//            }
//        }
        
        StringBuilder[] s = new StringBuilder[n];
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                s[i]=new StringBuilder();
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (a[i][j] == '*') {
                    int tr = i + dx[0];
                    int tc = j + dy[0];
                    int size = 1;
                    if (a[tr][tc] == '.') {
                        size += uf.size[uf.find(tr * (m + 2) + tc)];
                    }
                    for (int k = 1; k < 4; k++) {
                        boolean check = true;
                        int r1 = i + dx[k];
                        int c1 = j + dy[k];
                        if(a[r1][c1]!='.'){
                            continue;
                        }
                        for (int l = k - 1; l >= 0; l--) {
                            int r2 = i + dx[l];
                            int c2 = j + dy[l];
                            if (uf.connected(r1 * (m + 2) + c1, r2 * (m + 2) + c2)) {
                                check = false;
                                break;
                            }
                        }
                        if (check) {
                            size += uf.size[uf.find(r1*(m+2)+c1)];
                        }
                    }
                    s[i-1].append((size%10));
                }
                else{
                    s[i-1].append(".");
                }
            }
        }
        
        for(int i=0;i<n;i++){
            System.out.println(s[i]);
        }

    }

    static class UF {

        public int max = 1;
        private int[] size;
        private int[] parent;  // parent[i] = parent of i
        private byte[] rank;   // rank[i] = rank of subtree rooted at i (never more than 31)
        private int count;     // number of components

        public UF(int N) {
            if (N < 0) {
                throw new IllegalArgumentException();
            }
            count = N;
            parent = new int[N];
            rank = new byte[N];
            size = new int[N];
            for (int i = 0; i < N; i++) {
                parent[i] = i;
                rank[i] = 0;
                size[i] = 1;
            }
        }

        public void print(int id) {
            for (int i = 0; i < parent.length; i++) {
                if (parent[i] == parent[id]) {
                    System.out.print(i + " ");
                }
            }
            System.out.println();
        }

        public int find(int p) {
            if (p < 0 || p >= parent.length) {
                return -1;
            }
            while (p != parent[p]) {
                parent[p] = parent[parent[p]];    // path compression by halving
                p = parent[p];
            }
            return p;
        }

        public int count() {
            return count;
        }

        public boolean connected(int p, int q) {
            if (p >= rank.length || q >= rank.length) {
                return false;
            }

            return find(p) == find(q);
        }

        public boolean union(int p, int q) {

            if (p >= rank.length || q >= rank.length) {
                return false;
            }
            int rootP = find(p);
            int rootQ = find(q);
            if (rootP == rootQ) {
                return false;
            }

            // make root of smaller rank point to root of larger rank
            if (rank[rootP] < rank[rootQ]) {
                parent[rootP] = rootQ;
                size[rootQ] += size[rootP];
                if (size[rootQ] > max) {
                    max = size[rootQ];
                }
            } else if (rank[rootP] > rank[rootQ]) {
                parent[rootQ] = rootP;
                size[rootP] += size[rootQ];
                if (size[rootP] > max) {
                    max = size[rootP];
                }
            } else {
                parent[rootQ] = rootP;
                rank[rootP]++;
                size[rootP] += size[rootQ];
                if (size[rootP] > max) {
                    max = size[rootP];
                }
            }
            count--;
            return true;
        }

    }

    static class FasterScanner {

        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = System.in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        public long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }

}
