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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Alex
 */
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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskC {
        int get(int row, int col, int cols) {
            return row * cols + col;
        }

        int get(int row, int col, char[][] tab, boolean[][] visited) {
            if(visited[row][col] || tab[row][col] == '*') return 0;
            visited[row][col] = true;
            int res = 1;
            for(int i = 0; i < 4; i++) {
                int nrow = MiscUtils.DX4[i] + row, ncol = MiscUtils.DY4[i] + col;
                if(MiscUtils.isValidCell(nrow, ncol, tab.length, tab[0].length))
                    res += get(nrow, ncol, tab, visited);
            }
            return res;
        }

        int dp(int row, int col, char[][] tab, boolean[][] visited, HashMap<Integer, Integer> mem, int[][] issmem) {
            int isskey = issmem[row][col];
            if(mem.containsKey(isskey))
                return mem.get(isskey);
            int res = get(row, col, tab, visited);
            mem.put(isskey, res);
            return res;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int rows = in.readInt(), cols = in.readInt();
            char[][] tab = new char[rows][];
            for(int row = 0; row < rows; row++) tab[row] = IOUtils.readCharArray(in, cols);
            RecursiveIndependentSetSystem iss = new RecursiveIndependentSetSystem(rows * cols);
            for(int row = 0; row < rows; row++) {
                for(int col = 0; col < cols; col++) {
                    if(tab[row][col] == '*') continue;
                    if(row < rows - 1 && tab[row + 1][col] == '.')
                        iss.join(get(row, col, cols), get(row + 1, col, cols));
                    if(col < cols - 1 && tab[row][col + 1] == '.')
                        iss.join(get(row, col, cols), get(row, col + 1, cols));
                }
            }
            HashMap<Integer, Integer> mem = new HashMap<>();
            char[][] res = new char[rows][cols];
            boolean[][] visited = new boolean[rows][cols];
            ArrayUtils.fill(res, '.');
            int[][] issmem = new int[rows][cols];
            for(int row = 0; row < rows; row++) {
                for(int col = 0; col < cols; col++) {
                    issmem[row][col] = iss.get(get(row, col, cols));
                }
            }
            ArrayList<Integer> already = new ArrayList<>();
            for(int row = 0; row < rows; row++) {
                for(int col = 0; col < cols; col++) {
                    if(tab[row][col] == '.') continue;
                    already.clear();
                    int temp = 1;
                    for(int i = 0; i < 4; i++) {
                        int nrow = MiscUtils.DX4[i] + row, ncol = MiscUtils.DY4[i] + col;
                        if(MiscUtils.isValidCell(nrow, ncol, tab.length, tab[0].length) && !already.contains(issmem[nrow][ncol])) {
                            already.add(issmem[nrow][ncol]);
                            temp += dp(nrow, ncol, tab, visited, mem, issmem);
                        }
                    }
                    res[row][col] = (char) ('0' + temp % 10);
                }
            }
            for(char[] row : res) out.printLine(row);
        }

    }

    static interface IndependentSetSystem {
        public static interface Listener {
            public void joined(int joinedRoot, int root);

        }

    }

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

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

        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 readInt() {
            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 boolean isSpaceChar(int c) {
            if(filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public char readCharacter() {
            int c = read();
            while(isSpaceChar(c))
                c = read();
            return (char) c;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class MiscUtils {
        public static final int[] DX4 = {1, 0, -1, 0};
        public static final int[] DY4 = {0, -1, 0, 1};

        public static boolean isValidCell(int row, int column, int rowCount, int columnCount) {
            return row >= 0 && row < rowCount && column >= 0 && column < columnCount;
        }

    }

    static class ArrayUtils {
        public static void fill(char[][] array, char value) {
            for(char[] row : array)
                Arrays.fill(row, value);
        }

    }

    static class RecursiveIndependentSetSystem implements IndependentSetSystem {
        private final int[] color;
        private final int[] rank;
        private int setCount;
        private Listener listener;

        public RecursiveIndependentSetSystem(int size) {
            color = new int[size];
            rank = new int[size];
            for(int i = 0; i < size; i++)
                color[i] = i;
            setCount = size;
        }

        public RecursiveIndependentSetSystem(RecursiveIndependentSetSystem other) {
            color = other.color.clone();
            rank = other.rank.clone();
            setCount = other.setCount;
        }

        public boolean join(int first, int second) {
            first = get(first);
            second = get(second);
            if(first == second)
                return false;
            if(rank[first] < rank[second]) {
                int temp = first;
                first = second;
                second = temp;
            } else if(rank[first] == rank[second])
                rank[first]++;
            setCount--;
            color[second] = first;
            if(listener != null)
                listener.joined(second, first);
            return true;
        }

        public int get(int index) {
            if(color[index] == index)
                return index;
            return color[index] = get(color[index]);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

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

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

        public void printLine(char[] array) {
            writer.println(array);
        }

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

    }

    static class IOUtils {
        public static char[] readCharArray(InputReader in, int size) {
            char[] array = new char[size];
            for(int i = 0; i < size; i++)
                array[i] = in.readCharacter();
            return array;
        }

    }
}

