#include <bits/stdc++.h>
using namespace std;
const int MAXRC = 1010;
int r, c;
char grid[MAXRC][MAXRC];
int dir[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
char child[MAXRC][MAXRC][4];
int q[MAXRC * MAXRC][2], tail;
void add(int r1, int c1) {
  grid[r1][c1] = '?';
  q[tail][0] = r1;
  q[tail][1] = c1;
  tail++;
}
char used[12];
inline int ingrid(int r1, int c1) {
  return (r1 >= 0 && c1 >= 0 && r1 < r && c1 < c);
}
void update(int r1, int c1) {
  for (int j = (0); j < (4); j++) {
    int r2 = r1 + dir[j][0];
    int c2 = c1 + dir[j][1];
    if (ingrid(r2, c2) && grid[r2][c2] != '#' && grid[r2][c2] != '?') {
      used[grid[r2][c2] - '0'] = 1;
    }
  }
}
void fix(int r1, int c1) {
  if (grid[r1][c1] != '?') return;
  grid[r1][c1] = '9';
  for (int j = (0); j < (4); j++) {
    int r2 = r1 + dir[j][0];
    int c2 = c1 + dir[j][1];
    if (ingrid(r2, c2) && grid[r2][c2] != '?' && grid[r2][c2] != '#') {
      grid[r2][c2] = '9';
      for (int k = (0); k < (4); k++)
        if (child[r2][c2][k]) grid[r2 + dir[k][0]][c2 + dir[k][1]] = '9';
      return;
    }
  }
}
void show() {
  for (int i = (0); i < (r); i++) {
    printf("%s\n", grid[i]);
  }
}
int moo(int r1, int c1) {
  tail = 0;
  add(r1, c1);
  for (int i = (0); i < (tail); i++) {
    r1 = q[i][0];
    c1 = q[i][1];
    for (int j = (0); j < (4); j++) {
      child[r1][c1][j] = 0;
      int r2 = r1 + dir[j][0];
      int c2 = c1 + dir[j][1];
      if (ingrid(r2, c2) && grid[r2][c2] == '.') {
        child[r1][c1][j] = 1;
        add(r2, c2);
      }
    }
  }
  if (tail == 1) return 0;
  for (int i = tail - 1; i >= 0; --i) {
    r1 = q[i][0];
    c1 = q[i][1];
    memset(used, 0, sizeof(used));
    update(r1, c1);
    int cou = 0;
    for (int j = (0); j < (4); j++)
      if (child[r1][c1][j]) {
        int r2 = r1 + dir[j][0];
        int c2 = c1 + dir[j][1];
        if (grid[r2][c2] == '?') {
          cou++;
          update(r2, c2);
        } else
          child[r1][c1][j] = 0;
      }
    if (cou > 0) {
      char ch = 0;
      while (ch <= 9 && used[ch]) ch++;
      ch += '0';
      grid[r1][c1] = ch;
      for (int j = (0); j < (4); j++)
        if (child[r1][c1][j]) {
          int r2 = r1 + dir[j][0];
          int c2 = c1 + dir[j][1];
          grid[r2][c2] = ch;
        }
    }
  }
  fix(q[0][0], q[0][1]);
  return 1;
}
int main() {
  scanf("%d%d", &r, &c);
  for (int i = (0); i < (r); i++) scanf("%s", grid[i]);
  for (int i = (0); i < (r); i++)
    for (int j = (0); j < (c); j++)
      if (grid[i][j] == '.') {
        if (!moo(i, j)) {
          printf("-1\n");
          return 0;
        }
      }
  show();
  return 0;
}
