#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
int d[4][2] = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};
char a[N][N];
int v[N][N], q[N * N][2], color[N * N], vis[N][N];
int main() {
  int n, m, used[12], x, y, count = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  memset(v, 0, sizeof(v));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] != '#' && v[i][j] == 0)
        for (int k = 0; k < 4; k++) {
          x = i + d[k][0];
          y = j + d[k][1];
          if (x < 1 || y < 1 || x > n || y > m) continue;
          if (a[x][y] != '#' && v[x][y] == 0) {
            v[x][y] = v[i][j] = ++count;
            break;
          }
        }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] != '#' && v[i][j] == 0)
        for (int k = 0; k < 4; k++) {
          x = i + d[k][0];
          y = j + d[k][1];
          if (x < 1 || y < 1 || x > n || y > m) continue;
          if (a[x][y] != '#') {
            v[i][j] = v[x][y];
            break;
          }
        }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] != '#' && v[i][j] == 0) {
        printf("-1\n");
        exit(0);
      }
  memset(vis, 0, sizeof(vis));
  memset(color, -1, sizeof(color));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] != '#' && !vis[i][j]) {
        for (int k = 0; k < 10; k++) used[k] = false;
        int cc = v[i][j];
        int front = 0, back = 1;
        q[front][0] = i;
        q[front][1] = j;
        vis[i][j] = true;
        while (front < back) {
          x = q[front][0];
          y = q[front][1];
          front++;
          for (int k = 0; k < 4; k++) {
            int x1 = x + d[k][0];
            int y1 = y + d[k][1];
            if (x1 < 1 || x1 > n) continue;
            if (y1 < 1 || y1 > m) continue;
            if (a[x1][y1] == '#') continue;
            if (v[x1][y1] == cc) {
              if (vis[x1][y1]) continue;
              vis[x1][y1] = true;
              q[back][0] = x1;
              q[back][1] = y1;
              back++;
            } else if (color[v[x1][y1]] != -1)
              used[color[v[x1][y1]]] = true;
          }
        }
        int ch = 0;
        while (used[ch]) ch++;
        color[cc] = ch;
      }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      if (a[i][j] == '#')
        putchar('#');
      else
        putchar(char('0' + color[v[i][j]]));
    putchar('\n');
  }
  return 0;
}
