#include <bits/stdc++.h>
using namespace std;
const int N = 1111, P = 555555, DX[] = {-1, 0, 1, 0}, DY[] = {0, -1, 0, 1};
const int DDX[] = {-1, 0, 1, 2, 1, 0}, DDY[] = {0, -1, -1, 0, 1, 1};
int val[N][N], col[P];
vector<pair<int, int> > pos[P];
int n, m;
int findColor(int v) {
  set<int> cl;
  for (auto p : pos[v]) {
    for (int d = (0); d <= (3); d++) {
      int i = p.first + DX[d];
      int j = p.second + DY[d];
      int vv = val[i][j];
      if (vv > 0 && v != vv) {
        cl.insert(col[vv]);
      }
    }
  }
  int ans = 0;
  while (cl.find(ans) != cl.end()) ans++;
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = (1); i <= (n); i++) {
    string s;
    cin >> s;
    for (int j = (0); j <= ((int)(s).size()); j++) {
      val[i][j + 1] = s[j] == '.' ? 0 : -1;
    }
  }
  int k = 0;
  for (int i = (1); i <= (n); i++) {
    for (int j = (1); j <= (m - 1); j++) {
      if (!val[i][j] && !val[i][j + 1]) {
        val[i][j] = ++k;
        val[i][j + 1] = k;
        pos[k].push_back(make_pair(i, j));
        pos[k].push_back(make_pair(i, j + 1));
        col[k] = findColor(k);
      }
    }
  }
  for (int j = (1); j <= (m); j++) {
    for (int i = (1); i <= (n - 1); i++) {
      if (!val[i][j] && !val[i + 1][j]) {
        val[i][j] = ++k;
        val[i + 1][j] = k;
        pos[k].push_back(make_pair(i, j));
        pos[k].push_back(make_pair(i + 1, j));
        col[k] = findColor(k);
      }
    }
  }
  for (int i = (1); i <= (n); i++) {
    for (int j = (1); j <= (m); j++) {
      if (!val[i][j]) {
        bool found = false;
        for (int d = (0); d <= (3); d++) {
          int ii = i + DX[d];
          int jj = j + DY[d];
          int v = val[ii][jj];
          if (v > 0 && (int)(pos[v]).size() < 5) {
            pos[v].push_back(make_pair(i, j));
            val[i][j] = v;
            col[v] = findColor(v);
            found = true;
          }
        }
        if (!found) {
          cout << -1 << "\n";
          return 0;
        }
      }
    }
  }
  for (int i = (1); i <= (n); i++) {
    for (int j = (1); j <= (m); j++) {
      cout << (char)(val[i][j] < 0 ? '#' : '0' + col[val[i][j]]);
    }
    cout << "\n";
  }
  return 0;
}
