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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        CTheLabyrinth solver = new CTheLabyrinth();
        solver.solve(1, in, out);
        out.close();
    }

    static class CTheLabyrinth {
        private int n;
        private int m;

        private int index(int i, int j) {
            return i * m + j;
        }

        private boolean isValid(int x, int y) {
            return x >= 0 && x < n && y >= 0 && y < m;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            n = in.nextInt();
            m = in.nextInt();
            char[][] arr = new char[n][m];
            CTheLabyrinth.DisjointSet ds = new CTheLabyrinth.DisjointSet(n * m);
            for (int i = 0; i < n; i++) {
                String str = in.nextLine();
                for (int j = 0; j < m; j++) arr[i][j] = str.charAt(j);
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (arr[i][j] == '.') {
                        if (isValid(i - 1, j) && arr[i - 1][j] == '.') ds.union(index(i, j), index(i - 1, j));
                        if (isValid(i, j + 1) && arr[i][j + 1] == '.') ds.union(index(i, j), index(i, j + 1));
                        if (isValid(i + 1, j) && arr[i + 1][j] == '.') ds.union(index(i, j), index(i + 1, j));
                        if (isValid(i, j - 1) && arr[i][j - 1] == '.') ds.union(index(i, j), index(i, j - 1));
                    }
                }
            }
            HashSet<Integer> hs = new HashSet<>();
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (arr[i][j] == '.') out.print('.');
                    else {
                        hs.clear();
                        if (isValid(i - 1, j) && arr[i - 1][j] == '.') hs.add(ds.root(index(i - 1, j)));
                        if (isValid(i, j + 1) && arr[i][j + 1] == '.') hs.add(ds.root(index(i, j + 1)));
                        if (isValid(i + 1, j) && arr[i + 1][j] == '.') hs.add(ds.root(index(i + 1, j)));
                        if (isValid(i, j - 1) && arr[i][j - 1] == '.') hs.add(ds.root(index(i, j - 1)));
                        int res = 0;
                        for (int x : hs) res += ds.setSize[x];
                        res++;
                        res = Util.mod(res, 10);
                        out.print(res);
                    }

                }
                out.println();
            }
            out.flush();
        }

        static class DisjointSet {
            private int[] parent;
            private int[] setSize;
            private int numOfSets;

            private DisjointSet(int n) {
                parent = new int[n];
                setSize = new int[n];
                for (int i = 0; i < n; i++) {
                    setSize[i] = 1;
                    parent[i] = i;
                }
                numOfSets = n;
            }

            private int root(int x) {
                if (x == parent[x]) return x;
                return parent[x] = root(parent[x]);
            }

            private boolean _union(int n1, int n2) {
                if (n1 == n2) return false;
                if (setSize[n1] > setSize[n2]) {
                    parent[n2] = parent[n1];
                    setSize[n1] += setSize[n2];
                } else {
                    parent[n1] = parent[n2];
                    setSize[n2] += setSize[n1];
                }
                numOfSets--;
                return true;
            }

            private boolean union(int n1, int n2) {
                return _union(root(n1), root(n2));
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int numChars;

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

        public InputReader(FileInputStream file) {
            this.stream = file;
        }

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

        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 = (res << 3) + (res << 1) + c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        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();
        }

        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;
        }

    }

    static class Util {
        public static int mod(int a, int mod) {
            int res = a % mod;
            return res >= 0 ? res : res + mod;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;
        private ArrayList<String> res = new ArrayList<>();
        private StringBuilder sb = new StringBuilder("");

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void println() {
            res.add(sb.toString());
            sb = new StringBuilder("");
//        writer.println();
//        writer.flush();
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                sb.append(objects[i]);
            }
//        writer.println();
//        writer.flush();
        }

        public void close() {
//        flush();
            writer.close();
        }

        public void flush() {
            for (String str : res) writer.printf("%s\n", str);
            res.clear();
            sb = new StringBuilder("");
        }

    }
}

