/* @JUDGE_ID: 10853LE 10189 Java */ 

import java.lang.*;
import java.util.*;
import java.io.*;

class Minesweeper
{

/**
* Function from http://online-judge.uva.es/board/viewtopic.php?t=7429
*/
    static String readLn (int maxLg)  // utility function to read from stdin
    {
        byte lin[] = new byte [maxLg];
        int lg = 0, car = -1;
        String line = "";

        try
        {
            while (lg < maxLg)
            {
                car = System.in.read();
                if ((car < 0) || (car == '\n')) break;
                lin [lg++] += car;
            }
        }
        catch (IOException e)
        {
            return (null);
        }

        if ((car < 0) && (lg == 0)) return (null);  // eof
        return (new String (lin, 0, lg));
    }	
	
	public static void main(String[] args)
	{
		String output = new String();
		int currField = 1;
		String s = readLn(255);
		loop:
		while (s != null && s != "" && s != "\n")
		{
			StringTokenizer st = new StringTokenizer(s);
			if (!st.hasMoreTokens())
				break loop;
			int rows = Integer.parseInt(st.nextToken());
			int cols = Integer.parseInt(st.nextToken());
			char[][] mineMatrix = new char[rows][cols];
			for (int r = 0; r < rows; r++)
			{
				String ns = readLn(255);
				for (int c = 0; c < cols; c++)
				{
					mineMatrix[r][c] = ns.charAt(c);
				}
			}
			int[][] intMatrix = new int[rows][cols];
			
			for (int r = 0; r < rows; r++)
			{
				for (int c = 0; c < cols; c++)
				{
					if (mineMatrix[r][c] == '*')
					{
						intMatrix[r][c] = -1;
					}
					else
						{
						int count = 0;
						for (int offSetRow = -1; offSetRow <= 1; offSetRow++)
						{
							for (int offSetCol = -1; offSetCol <= 1; offSetCol++)
							{
								try
								{
									if (mineMatrix[r+offSetRow][c+offSetCol] == '*')
									{
										count++;
									}
								}
								catch (Exception e)
								{
										//AOB error, and nobody cares
								}
							}
						intMatrix[r][c] = count;
						}
					}
				}
			}		
			output = output + "Field #"+(currField++)+"\n";
			for (int r = 0; r < rows; r++)
			{
				for (int c = 0; c < cols; c++)
				{
					if (intMatrix[r][c] == -1)
					{
						output = output + "*";
					}
					else
					{
						output = output + intMatrix[r][c];					
					}
				}
				output = output + "\n";
			}
			output = output + "\n";
			s = readLn(255);
		}
		System.out.println(output);
	}
}
