#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
int n, m;
string a[MAXN];
int color[MAXN][MAXN];
pair<int, int> parent[MAXN][MAXN];
bool connected[MAXN][MAXN];
pair<int, int> Find(pair<int, int> x) {
  if (parent[x.first][x.second] == x) return x;
  parent[x.first][x.second] = Find(parent[x.first][x.second]);
  return parent[x.first][x.second];
}
void Union(pair<int, int> u, pair<int, int> v) {
  u = Find(u);
  v = Find(v);
  if (u == v) return;
  parent[v.first][v.second] = u;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      parent[i][j] = {i, j};
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m - 1; j++) {
      if (a[i][j] == '.' && a[i][j + 1] == '.') {
        if (connected[i][j] == false && connected[i][j + 1] == false) {
          connected[i][j] = true;
          connected[i][j + 1] = true;
          Union({i, j}, {i, j + 1});
        }
      }
    }
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '.' && a[i + 1][j] == '.') {
        if (connected[i][j] == false && connected[i + 1][j] == false) {
          connected[i][j] = true;
          connected[i + 1][j] = true;
          Union({i, j}, {i + 1, j});
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if ((i + j) % 2 == 0 && connected[i][j] == true) {
        color[Find({i, j}).first][Find({i, j}).second] = (i % 3) * 3 + j % 3;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '.' && connected[i][j] == false) {
        if (i - 1 >= 0 && connected[i - 1][j] == true)
          Union({i - 1, j}, {i, j});
        else if (i + 1 < n && connected[i + 1][j] == true)
          Union({i + 1, j}, {i, j});
        else if (j - 1 >= 0 && connected[i][j - 1] == true)
          Union({i, j - 1}, {i, j});
        else if (j + 1 < m && connected[i][j + 1] == true)
          Union({i, j + 1}, {i, j});
        else {
          cout << "-1" << '\n';
          return 0;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == '.')
        a[i][j] = '0' + color[Find({i, j}).first][Find({i, j}).second];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << a[i] << '\n';
  }
}
