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

/**
* Date: 
* Link:
*
* @author: Prasad Chaudhari
* @linkedIn: https://www.linkedin.com/in/prasad-chaudhari-841655a6/
* @git: https://github.com/Prasad-Chaudhari
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;

public class Main {

    public static void main(String[] args) throws Exception {
        FastIO in = new FastIO(args);
        int n = in.ni();
        int m = in.ni();
        char c[][] = new char[n][m];
        for (int i = 0; i < n; i++) {
            c[i] = in.next().toCharArray();
        }
        UnionFind uf = new UnionFind(n * m);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (c[i][j] == '.') {
                    if (i > 0 && c[i - 1][j] == '.') {
                        uf.union(code(i, j, n, m), code(i - 1, j, n, m));
                    }
                    if (i + 1 < n && c[i + 1][j] == '.') {
                        uf.union(code(i, j, n, m), code(i + 1, j, n, m));
                    }
                    if (j > 0 && c[i][j - 1] == '.') {
                        uf.union(code(i, j, n, m), code(i, j - 1, n, m));
                    }
                    if (j + 1 < m && c[i][j + 1] == '.') {
                        uf.union(code(i, j, n, m), code(i, j + 1, n, m));
                    }
                }
            }
        }
        char ans[][] = new char[n][m];
        for (int i = 0; i < n; i++)
            ans[i] = Arrays.copyOf(c[i], m);

        // for (int i = 0; i < n; i++) {
        //     for (int j = 0; j < m; j++) {
        //         if (c[i][j] == '*') {
        //             System.out.print("*");
        //         } else {
        //             System.out.print(uf.find(code(i, j, n, m)));
        //         }
        //     }
        //     System.out.println();
        // }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (c[i][j] == '*') {
                    Set<Integer> s = new HashSet<>();
                    if (i > 0 && c[i - 1][j] == '.') {
                        s.add(uf.find(code(i - 1, j, n, m)));
                    }
                    if (i + 1 < n && c[i + 1][j] == '.') {
                        s.add(uf.find(code(i + 1, j, n, m)));
                    }
                    if (j > 0 && c[i][j - 1] == '.') {
                        s.add(uf.find(code(i, j - 1, n, m)));
                    }
                    if (j + 1 < m && c[i][j + 1] == '.') {
                        s.add(uf.find(code(i, j + 1, n, m)));
                    }
                    int count = 1;
                    // System.out.print(i + " " + j + ": ");
                    for (int code : s) {
                        count += uf.size[uf.find(code)];
                        // System.out.print(code + "_" + uf.size[uf.find(code)] + ", ");
                    }
                    // System.out.println();
                    ans[i][j] = (char) ((count % 10) + '0');
                }
            }
        }
        for (char cc[] : ans)
            System.out.println(new String(cc));
        in.bw.flush();
    }

    static int code(int i, int j, int n, int m) {
        return i * m + j;
    }

    static class UnionFind {

        private int noOfComponents, n;
        private int component[], size[];
        private ArrayList<LinkedList<Integer>> members;

        public UnionFind(int p) {
            n = p;
            noOfComponents = n;
            component = new int[n + 1];
            size = new int[n + 1];
            members = new ArrayList<>();
            for (int i = 0; i <= n; i++) {
                component[i] = i;
                size[i] = 1;
                members.add(new LinkedList<Integer>());
                members.get(i).add(i);
            }
        }

        public int find(int k) {
            return component[k];
        }

        public void union(int a, int b) {
            a = find(a);
            b = find(b);
            if (a == b) {
                return;
            }
            if (size[a] > size[b]) {
                a = a ^ b;
                b = a ^ b;
                a = a ^ b;
            }
            LinkedList<Integer> membersofa = members.get(a);
            LinkedList<Integer> membersofb = members.get(b);
            size[b] = membersofa.size() + membersofb.size();
            while(!membersofa.isEmpty()){
                int member = membersofa.remove();
                component[member] = component[b];
                membersofb.add(member);
            }
            noOfComponents--;
        }

        public int noOfComponents() {
            return noOfComponents;
        }
    }

    static class Data implements Comparable<Data> {

        int a, b;

        public Data(int a, int b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public int compareTo(Data o) {
            if (a == o.a) {
                return Integer.compare(b, o.b);
            }
            return Integer.compare(a, o.a);
        }

        public static void sort(int a[]) {
            Data d[] = new Data[a.length];
            for (int i = 0; i < a.length; i++) {
                d[i] = new Data(a[i], 0);
            }
            Arrays.sort(d);
            for (int i = 0; i < a.length; i++) {
                a[i] = d[i].a;
            }
        }
    }

    static class FastIO {

        private final BufferedReader br;
        private final BufferedWriter bw;
        private String s[];
        private int index;

        public FastIO(String[] args) throws IOException {
            if (args.length > 1) {
                br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(args[0]))));
                bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(args[1]))));
            } else {
                br = new BufferedReader(new InputStreamReader(System.in));
                bw = new BufferedWriter(new OutputStreamWriter(System.out, "UTF-8"));
            }
            s = br.readLine().split(" ");
            index = 0;
        }

        public int ni() throws IOException {
            return Integer.parseInt(nextToken());
        }

        public double nd() throws IOException {
            return Double.parseDouble(nextToken());
        }

        public long nl() throws IOException {
            return Long.parseLong(nextToken());
        }

        public String next() throws IOException {
            return nextToken();
        }

        public String nli() throws IOException {
            try {
                return br.readLine();
            } catch (IOException ex) {

            }
            return null;
        }

        public int[] gia(int n) throws IOException {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }

        public int[] gia(int n, int start, int end) throws IOException {
            validate(n, start, end);
            int a[] = new int[n];
            for (int i = start; i < end; i++) {
                a[i] = ni();
            }
            return a;
        }

        public double[] gda(int n) throws IOException {
            double a[] = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }

        public double[] gda(int n, int start, int end) throws IOException {
            validate(n, start, end);
            double a[] = new double[n];
            for (int i = start; i < end; i++) {
                a[i] = nd();
            }
            return a;
        }

        public long[] gla(int n) throws IOException {
            long a[] = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }

        public long[] gla(int n, int start, int end) throws IOException {
            validate(n, start, end);
            long a[] = new long[n];
            for (int i = start; i < end; i++) {
                a[i] = nl();
            }
            return a;
        }

        public void print(String s) throws IOException {
            bw.write(s);
        }

        public void println(String s) throws IOException {
            bw.write(s);
            bw.newLine();
        }

        public void print(int s) throws IOException {
            bw.write(s + "");
        }

        public void println(int s) throws IOException {
            bw.write(s + "");
            bw.newLine();
        }

        public void print(long s) throws IOException {
            bw.write(s + "");
        }

        public void println(long s) throws IOException {
            bw.write(s + "");
            bw.newLine();
        }

        public void print(double s) throws IOException {
            bw.write(s + "");
        }

        public void println(double s) throws IOException {
            bw.write(s + "");
            bw.newLine();
        }

        private String nextToken() throws IndexOutOfBoundsException, IOException {
            if (index == s.length) {
                s = br.readLine().split(" ");
                index = 0;
            }
            return s[index++];
        }

        private void validate(int n, int start, int end) {
            if (start < 0 || end >= n) {
                throw new IllegalArgumentException();
            }
        }
    }
}
