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


public class TheLabyrinth
{

    /************************ SOLUTION STARTS HERE ************************/

    //DONT FORGET TO COMMIT AND PUSH TO GITHUB
    static class WeightedQuickUnionUF {
	int[] parent;   // parent[i] = parent of i
	int[] size;     // size[i] = number of sites in subtree rooted at i
	int count;      // number of components
	public WeightedQuickUnionUF(int N) {
	    count = N;
	    parent = new int[N];
	    size = new int[N];
	    for (int i = 0; i < N; i++) {
		parent[i] = i;
		size[i] = 1;
	    }
	}
	public int count() {
	    return count;
	}
	public int find(int p) {
	    //validate(p);
	    while (p != parent[p])
	    {
		//parent[p] = parent[parent[p]];    // path compression by halving
		p = parent[p];
	    }
	    return p;
	}

	public boolean connected(int p, int q) {
	    return find(p) == find(q);
	}
	public void union(int p, int q) {
	    int rootP = find(p);
	    int rootQ = find(q);
	    if (rootP == rootQ) return;

	    // make smaller root point to larger one
	    if (size[rootP] < size[rootQ]) {
		parent[rootP] = rootQ;
		size[rootQ] += size[rootP];	           
	    }
	    else {
		parent[rootQ] = rootP;
		size[rootP] += size[rootQ];
	    }
	    count--;
	}
    }


    static int r,c;
    static char arr[][];
    static boolean isValid(int i,int j)
    {
	if(i<0 || j<0 || i>=r || j>=c || arr[i][j] == '*')
	    return false;
	else
	    return true;
    }
    static int to1D(int i,int j)
    {
	return (i*c)+j;
    }
    static ArrayList<Integer> adj(int i,int j)
    {		
	ArrayList<Integer> adj  = new ArrayList<>();
	if(isValid(i+1, j))
	    adj.add(to1D(i+1,j));
	if(isValid(i-1, j))
	    adj.add(to1D(i-1, j));
	if(isValid(i, j+1))
	    adj.add(to1D(i, j+1));
	if(isValid(i, j-1))
	    adj.add(to1D(i, j-1));
	return adj;
    }

    private static int size(WeightedQuickUnionUF dsu,int p)
    {
	return dsu.size[dsu.find(p)];
    }
    private static void solve(FastScanner s1, FastWriter out){

	r = s1.nextInt();
	c = s1.nextInt();
	arr = new char[r][c];
	for(int i = 0 ;i<r;i++)
	    arr[i] = s1.next().toCharArray();

	WeightedQuickUnionUF dsu = new WeightedQuickUnionUF(r*c);
	for(int i=0;i<r;i++)
	{
	    for(int j=0;j<c;j++)
	    {
		int u = to1D(i,j);
		//System.out.println("i="+i+"j="+j+" adj "+adj(i,j));
		if(arr[i][j] == '.')
		{
		    for(int v : adj(i, j))
			dsu.union(u, v);
		}
	    }
	}

	for(int i=0;i<r;i++)
	{
	    for(int j=0;j<c;j++)
	    {
		if(arr[i][j] == '.')
		    out.print('.');
		else
		{
		    ArrayList<Integer> arl = adj(i,j);
		    int len = arl.size();
		    int total = 1;
		    TreeSet<Integer> set = new TreeSet<>(arl); 
		    while(set.size()>0)
		    {
			int p = set.pollFirst();	
			ArrayList<Integer> TBR = new ArrayList<>();
			for(int q:set)
			    if(dsu.connected(p, q))
				TBR.add(q);

			for(int q:TBR)
			    set.remove(q);

			total += size(dsu,p);
		    }
		    out.print(total%10);
		}
	    }
	    out.println();
	}

    }

    /************************ SOLUTION ENDS HERE ************************/



    /************************ TEMPLATE STARTS HERE ************************/

    public static void main(String []args) throws IOException {
	FastScanner in  = new FastScanner(System.in);
	FastWriter  out = new FastWriter(System.out);
	solve(in, out);
	in.close();
	out.close();
    }    

    static class FastScanner{
	public BufferedReader reader;
	public StringTokenizer st;
	public FastScanner(InputStream stream){
	    reader = new BufferedReader(new InputStreamReader(stream));
	    st = null;
	}
	public String next(){
	    while(st == null || !st.hasMoreTokens()){
		try{
		    String line = reader.readLine();
		    if(line == null) return null;
		    st = new StringTokenizer(line);
		}catch (Exception e){
		    throw (new RuntimeException());
		}
	    }
	    return st.nextToken();
	}
	public String nextLine(){
	    String str = null;
	    try {
		str = reader.readLine();
	    } catch (IOException e) {
		e.printStackTrace();
	    }
	    return str;
	}
	public int nextInt(){
	    return Integer.parseInt(next());
	}
	public long nextLong(){
	    return Long.parseLong(next());
	}
	public double nextDouble(){
	    return Double.parseDouble(next());
	}
	int[] nextIntArray(int n) {
	    int[] arr = new int[n];
	    for (int i = 0; i < n; i++) {
		arr[i] = nextInt();
	    }
	    return arr;
	}

	long[] nextLongArray(int n) {
	    long[] arr = new long[n];
	    for (int i = 0; i < n; i++) {
		arr[i] = nextLong();
	    }
	    return arr;
	}
	public void close(){	
	    try{ reader.close(); } catch(IOException e){e.printStackTrace();}
	}
    }
    static class FastWriter{
	BufferedWriter writer;
	public FastWriter(OutputStream stream){
	    writer = new BufferedWriter(new OutputStreamWriter(stream));
	}
	public void print(int i) {
	    print(Integer.toString(i));
	}
	public void println(int i) {
	    print(Integer.toString(i));
	    print('\n');
	}
	public void print(long i) {
	    print(Long.toString(i));
	}
	public void println(long i) {
	    print(Long.toString(i));
	    print('\n');
	}
	public void print(double i) {
	    print(Double.toString(i));
	}
	public void print(boolean i) {
	    print(Boolean.toString(i));
	}
	public void print(char i) {
	    try{writer.write(i);} catch(IOException e){e.printStackTrace();}
	}
	public void print(String s){
	    try{writer.write(s);} catch(IOException e){e.printStackTrace();}
	}
	public void println(String s){
	    try{writer.write(s);writer.write('\n');} catch(IOException e){e.printStackTrace();}
	}
	public void println(){
	    try{writer.write('\n');} catch(IOException e){e.printStackTrace();}
	}
	public void print(int arr[])
	{
	    for (int i = 0; i < arr.length; i++) {
		print(arr[i]);
		print(' ');
	    }
	}
	public void close(){
	    try{writer.close();} catch(IOException e){e.printStackTrace();}
	}
    }

    /************************ TEMPLATE ENDS HERE ************************/
}
