#include <bits/stdc++.h> using namespace std; int main () { int n,m; int count=0; while(1) { cin>> m >> n; if (n ==0 && m ==0) break; count++; if (count > 1) cout << '\n'; int board[102][102] = {0}; for (int i=1; i<m+1; i++) for (int j=1; j<n+1; j++) { char mines; cin >> mines; if (mines == '*') { board[i][j] = -1; if (board[i-1][j] != -1) board[i-1][j]++; //top if (board[i-1][j-1] != -1) board[i-1][j-1]++; //top left if (board[i-1][j+1] != -1) board[i-1][j+1]++; //top right if (board[i][j-1] != -1) board[i][j-1]++;//left if (board[i+1][j] != -1) board[i+1][j]++; // bottom if (board[i+1][j+1] != -1) board[i+1][j+1]++; //bottom right if (board[i+1][j-1] != -1) board[i+1][j-1]++; //bottom right if (board[i][j+1] != -1) board[i][j+1]++; //right } } cout << "Field #" << count << ":\n"; for (int i=1; i<m+1; i++) { for (int j=1; j<n+1; j++) { if (board[i][j] == -1) cout << '*'; else cout << board[i][j]; } cout << "\n"; } } return 0; }