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 C {
 
	public static int[] dx = {1, -1, 0, 0};
	public static int[] dy = {0, 0, 1, -1};
    public static void solve() {
        Kattio in = new Kattio(System.in);
       	
       	int n = in.nextInt();
       	int m = in.nextInt();

       	int[] ccsizes = new int[n*m + 1];
       	int[][] vis = new int[n][m]; 
       	char[][] grid = new char[n][m];
       	for(int i = 0; i < n; i++) {
       		grid[i] = in.next().toCharArray();
       	}

       	int cnt = 1;
       	for(int i = 0; i < n; i++) {
       		for(int j = 0; j <m; j++) {
       			if(grid[i][j] == '*') continue;
       			if(vis[i][j] == 0) {

       				Stack<Pair> stk = new Stack();
       				stk.push(new Pair(i, j));

       				int size = 0;
       				while(!stk.empty()) {

       					Pair p = stk.pop();
       					int x = p.f;
       					int y = p.s;


       					if(vis[x][y] != 0) continue;
       					vis[x][y] = cnt;
       					++size;

       					for(int ii = 0; ii < dx.length; ii++) {
       						int xx = x + dx[ii];
       						int yy = y + dy[ii];
       						if(xx < 0 || xx >= n) continue;
       						if(yy < 0 || yy >= m) continue;
       						if(grid[xx][yy] != '.') continue;

       						stk.push(new Pair(xx, yy));
       					}

       				}
       				
       				ccsizes[cnt++] = size;
       			}
       		}
       	}


       	System.err.println("hy");
       	for(int i = 0; i < n ;i++) {
       		for(int j = 0; j < m; j++) {
       			if(grid[i][j] == '.') in.print(".");
       			else {
       				int ans = 1;
       				LinkedList<Integer> visited = new LinkedList();
       				for(int ii = 0; ii < dx.length; ii++) {
       					int xx = i + dx[ii];
       					int yy = j + dy[ii];

       					if(xx < 0 || xx >= n) continue;
       					if(yy < 0 || yy >= m) continue;
       					if(grid[xx][yy] == '.') {
       						if(visited.contains(vis[xx][yy])) continue;
       						ans += ccsizes[vis[xx][yy]];
       						visited.add(vis[xx][yy]);
       					}
       				}

       				in.print(ans % 10);
       			}
       		} in.println();
       	}


        in.flush();
        in.close();
    }
 
    public static void main(String args[] ) throws Exception {


        Thread t = new Thread(null, null, "~", Runtime.getRuntime().maxMemory()){
            @Override
            public void run() {
                solve();
            }
        };

        t.start();
        t.join();

    }

    private static class Kattio extends PrintWriter {
 
        private BufferedReader r;
        private String line;
        private StringTokenizer st;
        private String token;
        
        public Kattio(InputStream i) {
            super(new BufferedOutputStream(System.out));
            r = new BufferedReader(new InputStreamReader(i));
        }
        public Kattio(InputStream i, OutputStream o) {
            super(new BufferedOutputStream(o));
            r = new BufferedReader(new InputStreamReader(i));
        }
 
        public boolean hasNext() {
            return peekToken() != null;
        }
 
        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
 
        public double nextDouble() { 
            return Double.parseDouble(nextToken());
        }
 
        public long nextLong() {
            return Long.parseLong(nextToken());
        }
 
        public String next() {
            return nextToken();
        }
        
        public String nextLine() {
            token = null;
            st = null;
            try {
                return r.readLine();
            } catch (IOException e) {
                return null;
            }
        }
 
        private String peekToken() {
            if (token == null) 
                try {
                    while (st == null || !st.hasMoreTokens()) {
                        line = r.readLine();
                        if (line == null) return null;
                        st = new StringTokenizer(line);
                    }
                    token = st.nextToken();
                } catch (IOException e) { }
            return token;
        }
 
        private String nextToken() {
            String ans = peekToken();
            token = null;
            return ans;
        }
    }
}

class UnionFind {                                              
  private Vector<Integer> p, rank, setSize;
  private int numSets;
 
  public UnionFind(int N) {
    p = new Vector<Integer>(N);
    rank = new Vector<Integer>(N);
    setSize = new Vector<Integer>(N);
    numSets = N;
    for (int i = 0; i < N; i++) {
      p.add(i);
      rank.add(0);
      setSize.add(1);
    }
  }
 
  public int findSet(int i) { 
    if (p.get(i) == i) return i;
    else {
      int ret = findSet(p.get(i)); p.set(i, ret);
      return ret; } }
 
  public Boolean isSameSet(int i, int j) { return findSet(i) == findSet(j); }
 
  public void unionSet(int i, int j) { 
    if (!isSameSet(i, j)) { numSets--; 
    int x = findSet(i), y = findSet(j);
    // rank is used to keep the tree short
    if (rank.get(x) > rank.get(y)) { p.set(y, x); setSize.set(x, setSize.get(x) + setSize.get(y)); }
    else                           { p.set(x, y); setSize.set(y, setSize.get(y) + setSize.get(x));
                                     if (rank.get(x) == rank.get(y)) rank.set(y, rank.get(y) + 1); } } }
  public int numDisjointSets() { return numSets; }
  public int sizeOfSet(int i) { return setSize.get(findSet(i)); }
}
 
class Pair {
	int f, s;

	public Pair(int f, int s) {
		this.f = f;
		this.s = s;
	}
}