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.*;
import java.util.*;
import java.util.stream.*;

public class CF5C {
    private static boolean debug = false;

    private static int N, M;
    private static boolean[][] A;

    private static void solveProblem(InputStream instr) throws Exception {
        InputReader sc = new InputReader(instr);
        int testCount = 1;
        if (debug) {
            testCount = sc.nextInt();
        }

        for (int t = 1; t <= testCount; t++) {
            printDebug("------ " + t + " ------");
            N = sc.nextInt();
            M = sc.nextInt();
            A = new boolean[N + 2][M + 2];
            for(int i = 0; i < N; i++){
                char[] str = sc.next().toCharArray();
                for(int j = 0; j < M; j++){
                    A[i+1][j+1] = (str[j] == '.');
                }
            }
            Object result = solveTestCase();
            System.out.println(result);
        }
    }


    private static Object solveTestCase() {
        List<StringBuilder> answer = new ArrayList<>();
       int[][] visited = new int[N+2][M+2];

        int code = 1;
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= M; j++) {
                if(visited[i][j] == 0 && A[i][j]) {
                    map.put(code, getCount(i, j, visited, code));
                    code++;
                }
            }
        }
        for(int i = 1; i <= N; i++){
            StringBuilder builder = new StringBuilder();
            answer.add(builder);
            for(int j = 1; j <= M; j++) {
                if(A[i][j]){
                    builder.append(".");
                    continue;
                }
                Set<Integer> codes = new HashSet<>();
                Pair cell = new Pair(i, j);
                int count = 0;
                for(int a = cell.x-1; a <= cell.x + 1; a++) {
                    for (int b = cell.y - 1; b <= cell.y + 1; b++) {
                        if(!A[a][b]){
                            continue;
                        }
                        if ((a == cell.x && b == cell.y)) {
                            continue;
                        }
                        if(a == cell.x || b == cell.y) {
                            if(!codes.contains(visited[a][b])) {
                                count += map.get(visited[a][b]);
                                codes.add(visited[a][b]);
                            }
                        }
                    }
                }
                count++;
                builder.append(count == 0 ? "." : (count % 10));
                A[i][j] = false;
            }
        }
        return joinValues(answer, "\n");
    }



    private static int getCount(int i, int j, int[][] visited , int code){
        int count = 0;
        Stack<Pair> stack = new Stack<>();
        stack.push(new Pair(i, j));
        while(!stack.empty()){
            Pair cell = stack.pop();
            if(visited[cell.x][cell.y] == 0){
                visited[cell.x][cell.y] = code;
                count++;
                for(int a = cell.x-1; a <= cell.x + 1; a++) {
                    for (int b = cell.y - 1; b <= cell.y + 1; b++) {
                        if(visited[a][b] != 0 || !A[a][b]){
                            continue;
                        }
                        if ((a == cell.x && b == cell.y)) {
                            continue;
                        }
                        if(a == cell.x || b == cell.y) {
                            stack.push(new Pair(a, b));
                        }
                    }
                }
            }
        }
        return count;
    }

    private static int[] readInts(InputReader sc, int N) throws Exception {
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        return arr;
    }

    private static String joinValues(List<? extends Object> list, String delim) {
        return list.stream().map(Object::toString).collect(Collectors.joining(delim));
    }

    private static String joinValues(int[] arr, String delim) {
        List<Object> list = new ArrayList<>();
        for (Object value : arr) {
            list.add(value);
        }
        return list.stream().map(Object::toString).collect(Collectors.joining(delim));
    }

    private static class Pair {
        int x, y;
        Pair(int x, int y){
            this.x = x;
            this.y = y;
        }
    }

    public static void printDebug(Object str) {
        if (debug) {
            System.out.println("DEBUG: " + str);
        }
    }


    private static void printOut(String out) {
        System.out.println(out);
    }

    public static String printArr(int[] arr) {
        StringBuilder builder = new StringBuilder();
        for (int in : arr) {
            builder.append(in).append(" ");
        }
        return builder.toString();
    }

    public static void shuffle(int[] array) {
        Random rand = new Random();
        for (int i = 0; i < array.length; i++) {
            int x = rand.nextInt(array.length - i);
            int idx = x + i;
            int tmp = array[idx];
            array[idx] = array[i];
            array[i] = tmp;
        }
    }
    private static final class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[1024];
        private int curChar;
        private int Chars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int read() throws Exception {
            if (curChar >= Chars) {
                curChar = 0;
                Chars = stream.read(buf);
                if (Chars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public final int nextInt() throws Exception {
            return (int)nextLong();
        }

        public final long nextLong() throws Exception {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
                if (c == -1)
                    throw new IOException();
            }
            boolean negative = false;
            if (c == '-') {
                negative = true;
                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 negative ? (-res) : (res);
        }

        public final int[] nextIntBrray(int size) throws Exception {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++)
                arr[i] = nextInt();
            return arr;
        }

        public final String next() throws Exception {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char)c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public final String nextLine() throws Exception {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char)c);
                c = read();
            } while (c != '\n' && c != -1);
            return res.toString();
        }

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

    public static void main(String[] args) throws Exception {
        long currTime = System.currentTimeMillis();
        try {
            if (new File("input.in").exists()) {
                debug = true;
            }
        } catch (Throwable ex) {

        }
        if (debug) {
            solveProblem(new FileInputStream(new File("input.in")));
            System.out.println("Time: " + (System.currentTimeMillis() - currTime));
        } else {
            solveProblem(System.in);
        }
    }

}
