#include <bits/stdc++.h>
using namespace std;
int n, m;
int k;
bool debug = false;
char mp[1005][1005];
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
char getc(int i, int j) { return (i % 3 * 3 + j % 3) + '0'; }
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) scanf("%s", mp[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m - 1; j++) {
      if (mp[i][j] == '.' && mp[i][j + 1] == '.') {
        mp[i][j] = mp[i][j + 1] = (i + j) & 1 ? getc(i, j + 1) : getc(i, j);
      }
    }
  for (int i = 0; i < n - 1; i++)
    for (int j = 0; j < m; j++) {
      if (mp[i][j] == '.' && mp[i + 1][j] == '.') {
        mp[i][j] = mp[i + 1][j] = (i + j) & 1 ? getc(i + 1, j) : getc(i, j);
      }
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (mp[i][j] == '.') {
        for (int kk = 0; kk < 4; kk++) {
          int x = i + dx[kk], y = j + dy[kk];
          if (x >= 0 && y >= 0 && x < n && y < m && mp[x][y] != '#') {
            mp[i][j] = mp[x][y];
            break;
          } else if (kk == 3) {
            puts("-1");
            return 0;
          }
        }
      }
  for (int i = 0; i < n; i++) puts(mp[i]);
  return 0;
}
