#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const int d[4][2] = {0, -1, 0, 1, -1, 0, 1, 0};
int a[N][N], c[N][N];
int v[N * N][5];
void dfs(int x, int y, int t) {
  int i, p, q;
  c[x][y] = t;
  for (i = 0; i < 4; i++) {
    p = x + d[i][0];
    q = y + d[i][1];
    if (a[p][q] > 0) {
      if (a[p][q] == a[x][y]) {
        if (c[p][q] == 0) dfs(p, q, t);
      } else
        v[a[p][q]][t] = 1;
    }
  }
}
int main() {
  int m, n, i, j, s, x, y, l, k;
  char ch;
  scanf("%d%d", &m, &n);
  memset(a, -1, sizeof(a));
  for (i = 1; i <= m; i++)
    for (j = 1; j <= n; j++) {
      scanf(" %c", &ch);
      if (ch == '.') a[i][j] = 0;
    }
  l = 0;
  for (i = 1; i <= m; i++)
    for (j = 1; j <= n; j++)
      if (a[i][j] == 0) {
        s = 1;
        for (k = 0; k < 4; k++) {
          x = i + d[k][0];
          y = j + d[k][1];
          if (a[x][y] == 0) {
            s++;
            break;
          }
        }
        if (s == 2) a[i][j] = a[x][y] = ++l;
      }
  for (i = 1; i <= m; i++)
    for (j = 1; j <= n; j++)
      if (a[i][j] == 0) {
        for (k = 0; k < 4; k++) {
          x = i + d[k][0];
          y = j + d[k][1];
          if (a[x][y] > 0) {
            a[i][j] = a[x][y];
            break;
          }
        }
        if (k >= 4) {
          printf("-1\n");
          return 0;
        }
      }
  for (i = 1; i <= m; i++)
    for (j = 1; j <= n; j++)
      if (a[i][j] > 0 && c[i][j] == 0) {
        for (k = 1; k <= 4; k++)
          if (v[a[i][j]][k] == 0) break;
        dfs(i, j, k);
      }
  for (i = 1; i <= m; i++) {
    for (j = 1; j <= n; j++)
      if (a[i][j] == -1)
        printf("#");
      else
        printf("%d", c[i][j]);
    printf("\n");
  }
}
