#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W;
  cin >> H >> W;
  string S1, S2;
  cin >> S1;
  for (int j = 0; j < H; j++) {
    cin >> S2;
    for (int k = 0; k < W; k++) {
      if (S1.at(k) == '.') {
        S1.at(k) = '0';
      }
      if (S2.at(k) == '.') {
        S2.at(k) = '0';
      }
    }
    for (int i = 0; i < W - 1; i++) {
      if (i == 0) {
        if (S1.at(i) == '#') {
          if (S2.at(i) != '#') {
            S2.at(i)++;
          }
          if (S2.at(i + 1) != '#') {
            S2.at(i + 1)++;
          }
          if (S1.at(i + 1) != '#') {
            S1.at(i + 1)++;
          }
        }
        if (S2.at(i) == '#') {
          if (S1.at(i) != '#') {
            S1.at(i)++;
          }
          if (S1.at(i + 1) != '#') {
            S1.at(i + 1)++;
          }
        }
        continue;
      }
      if (i != 0) {
        if (S1.at(i) == '#') {
          if (S2.at(i) != '#') {
            S2.at(i)++;
          }
          if (S2.at(i - 1) != '#') {
            S2.at(i - 1)++;
          }
          if (S1.at(i - 1) != '#') {
            S1.at(i - 1)++;
          }
        }
        if (S2.at(i) == '#') {
          if (S1.at(i) != '#') {
            S1.at(i)++;
          }
          if (S1.at(i - 1) != '#') {
            S1.at(i - 1)++;
          }
        }
        if (i == W - 1) {
          continue;
        }
        if (S1.at(i) == '#') {
          if (S2.at(i + 1) != '#') {
            S2.at(i + 1)++;
          }
          if (S1.at(i + 1) != '#') {
            S1.at(i + 1)++;
          }
        }
        if (S2.at(i) == '#') {
          if (S1.at(i + 1) != '#') {
            S1.at(i + 1)++;
          }
        }
      }
    }
    cout << S1 << endl;
    S1 = S2;
  }
  cout << S2 << endl;
}
