#include <bits/stdc++.h>
#include <sstream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int Check(int, int, int, int, string* );
int main() {
  ostringstream oss;
  string s[50];
  int num[50][50] = {};
  int h, w;
  
  cin >> h >> w;
  rep(i, h){
	rep(j, w){
      if(s[i].at(j) == '#')
        num[i][j] = 9;
      else
      	num[i][j] = Check(i, j, h, w, s[i]);
    }
  }
  
  rep(i,h){
  	rep(j, w){
      char c;
      oss << num[i][j];
      c = oss.str().c_str();
      if(c == '9')
        s[i].at(j) == '#';
      else
        s[i].at(j) == c;  
    }
  }
  
  rep(i, h)
    cout << s[i] << endl;
  
}

void Check(int i, int j, int h, int w, string* s){
  int rp_h = 3, rp_w = 3, h_PorD = -1, w_LorR = -1;
  int count = 0;
  
  if(i % (h - 1) == 0){
    rp_h--;
    if(i == 0)
      h_PorD = 1;
  }
  if( j % (w - 1) == 0){
    rp_w--;
    if(j == 0)
      w_LorR == 1;
  }
  
  rep(k, rp_h){
  	rep(l, rp_w){
      if(s[( i + k ) + h_PorD ].at((j + l) + w_LorR) == '#')
              	count++;
    }
  }    
  }
  return count;
}


