#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, sa, sb = "error";
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    if (i == 0) cin >> s;
    cin >> sa;
    for (int j = 0; j < W; j++) {
      if (s.at(j) != '#') {
        if (s.at(j) == '.') s.at(j) = '0';
      } else {
        if (i != 0) {
          if (j != 0) {
            if (sb.at(j - 1) == '0')
              sb.at(j - 1) = '1';
            else if (sb.at(j - 1) == '1')
              sb.at(j - 1) = '2';
            else if (sb.at(j - 1) == '2')
              sb.at(j - 1) = '3';
            else if (sb.at(j - 1) == '3')
              sb.at(j - 1) = '4';
            else if (sb.at(j - 1) == '4')
              sb.at(j - 1) = '5';
            else if (sb.at(j - 1) == '5')
              sb.at(j - 1) = '6';
            else if (sb.at(j - 1) == '6')
              sb.at(j - 1) = '7';
            else if (sb.at(j - 1) == '7')
              sb.at(j - 1) = '8';
          }
          if (sb.at(j) == '0')
            sb.at(j) = '1';
          else if (sb.at(j) == '1')
            sb.at(j) = '2';
          else if (sb.at(j) == '2')
            sb.at(j) = '3';
          else if (sb.at(j) == '3')
            sb.at(j) = '4';
          else if (sb.at(j) == '4')
            sb.at(j) = '5';
          else if (sb.at(j) == '5')
            sb.at(j) = '6';
          else if (sb.at(j) == '6')
            sb.at(j) = '7';
          else if (sb.at(j) == '7')
            sb.at(j) = '8';
          if (j != W - 1) {
            if (sb.at(j + 1) == '0')
              sb.at(j + 1) = '1';
            else if (sb.at(j + 1) == '1')
              sb.at(j + 1) = '2';
            else if (sb.at(j + 1) == '2')
              sb.at(j + 1) = '3';
            else if (sb.at(j + 1) == '3')
              sb.at(j + 1) = '4';
            else if (sb.at(j + 1) == '4')
              sb.at(j + 1) = '5';
            else if (sb.at(j + 1) == '5')
              sb.at(j + 1) = '6';
            else if (sb.at(j + 1) == '6')
              sb.at(j + 1) = '7';
            else if (sb.at(j + 1) == '7')
              sb.at(j + 1) = '8';
          }
        }
        if (j != 0) {
          if (s.at(j - 1) == '0')
            s.at(j - 1) = '1';
          else if (s.at(j - 1) == '1')
            s.at(j - 1) = '2';
          else if (s.at(j - 1) == '2')
            s.at(j - 1) = '3';
          else if (s.at(j - 1) == '3')
            s.at(j - 1) = '4';
          else if (s.at(j - 1) == '4')
            s.at(j - 1) = '5';
          else if (s.at(j - 1) == '5')
            s.at(j - 1) = '6';
          else if (s.at(j - 1) == '6')
            s.at(j - 1) = '7';
          else if (s.at(j - 1) == '7')
            s.at(j - 1) = '8';
        }
        if (j != W - 1) {
          if (s.at(j + 1) == '.')
            s.at(j + 1) = '1';
          else if (s.at(j + 1) == '1')
            s.at(j + 1) = '2';
          else if (s.at(j + 1) == '2')
            s.at(j + 1) = '3';
          else if (s.at(j + 1) == '3')
            s.at(j + 1) = '4';
          else if (s.at(j + 1) == '4')
            s.at(j + 1) = '5';
          else if (s.at(j + 1) == '5')
            s.at(j + 1) = '6';
          else if (s.at(j + 1) == '6')
            s.at(j + 1) = '7';
          else if (s.at(j + 1) == '7')
            s.at(j + 1) = '8';
        }
        if (j != 0) {
          if (sa.at(j - 1) == '.')
            sa.at(j - 1) = '1';
          else if (sa.at(j - 1) == '1')
            sa.at(j - 1) = '2';
          else if (sa.at(j - 1) == '2')
            sa.at(j - 1) = '3';
          else if (sa.at(j - 1) == '3')
            sa.at(j - 1) = '4';
          else if (sa.at(j - 1) == '4')
            sa.at(j - 1) = '5';
          else if (sa.at(j - 1) == '5')
            sa.at(j - 1) = '6';
          else if (sa.at(j - 1) == '6')
            sa.at(j - 1) = '7';
          else if (sa.at(j - 1) == '7')
            sa.at(j - 1) = '8';
        }
        if (sa.at(j) == '.')
          sa.at(j) = '1';
        else if (sa.at(j) == '1')
          sa.at(j) = '2';
        else if (sa.at(j) == '2')
          sa.at(j) = '3';
        else if (sa.at(j) == '3')
          sa.at(j) = '4';
        else if (sa.at(j) == '4')
          sa.at(j) = '5';
        else if (sa.at(j) == '5')
          sa.at(j) = '6';
        else if (sa.at(j) == '6')
          sa.at(j) = '7';
        else if (sa.at(j) == '7')
          sa.at(j) = '8';
        if (j != W - 1) {
          if (sa.at(j + 1) == '.')
            sa.at(j + 1) = '1';
          else if (sa.at(j + 1) == '1')
            sa.at(j + 1) = '2';
          else if (sa.at(j + 1) == '2')
            sa.at(j + 1) = '3';
          else if (sa.at(j + 1) == '3')
            sa.at(j + 1) = '4';
          else if (sa.at(j + 1) == '4')
            sa.at(j + 1) = '5';
          else if (sa.at(j + 1) == '5')
            sa.at(j + 1) = '6';
          else if (sa.at(j + 1) == '6')
            sa.at(j + 1) = '7';
          else if (sa.at(j + 1) == '7')
            sa.at(j + 1) = '8';
        }
      }
    }
    if (i) cout << sb << endl;
    if (i == H - 1) cout << s << endl;
    sb = s;
    s = sa;
  }
}
