#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
int n, m, r[1111][1111], d[10];
char a[1111][1111];
vector<pair<int, int> > b;
int Count(int x, int y) {
  int i, xx, yy;
  for (i = 0; i <= 3; i++) {
    xx = x + dx[i];
    yy = y + dy[i];
    if (xx && yy && xx <= m && yy <= n && a[xx][yy] == '.' && r[xx][yy] == -1)
      return 1;
  }
  return 0;
}
void fill(int x, int y, int c) {
  int i, xx, yy;
  for (i = 0; i <= 3; i++) {
    xx = x + dx[i];
    yy = y + dy[i];
    if (xx && yy && xx <= m && yy <= n && a[xx][yy] == '.' && r[xx][yy] == -1 &&
        !Count(xx, yy))
      b.push_back(make_pair(xx, yy));
  }
}
void visit(int x, int y) {
  int i, j, xx, yy, X = 0, Y;
  b.clear();
  for (i = 0; i <= 9; i++) d[i] = 0;
  for (i = 0; i <= 3; i++) {
    xx = x + dx[i];
    yy = y + dy[i];
    if (xx && yy && xx <= m && yy <= n && a[xx][yy] == '.' && r[xx][yy] == -1)
      X = xx, Y = yy;
  }
  if (!X) {
    cout << -1 << endl;
    exit(0);
  }
  b.push_back(make_pair(x, y));
  b.push_back(make_pair(X, Y));
  r[x][y] = r[X][Y] = -2;
  fill(x, y, i);
  fill(X, Y, i);
  for (j = 0; j <= b.size() - 1; j++) {
    x = b[j].first;
    y = b[j].second;
    for (i = 0; i <= 3; i++) {
      xx = x + dx[i];
      yy = y + dy[i];
      if (xx && yy && xx <= m && yy <= n && r[xx][yy] >= 0) d[r[xx][yy]] = 1;
    }
  }
  for (i = 0; i <= 9; i++)
    if (!d[i]) break;
  for (j = 0; j <= b.size() - 1; j++) r[b[j].first][b[j].second] = i;
}
int main() {
  int i, j;
  cin >> m >> n;
  for (i = 1; i <= m; i++) scanf("%s", &a[i]);
  for (i = 1; i <= m; i++)
    for (j = n; j >= 1; j--) a[i][j] = a[i][j - 1], r[i][j] = -1;
  for (i = 1; i <= m; i++)
    for (j = 1; j <= n; j++)
      if (r[i][j] < 0 && a[i][j] == '.') visit(i, j);
  for (i = 1; i <= m; i++) {
    for (j = 1; j <= n; j++)
      if (r[i][j] >= 0)
        printf("%d", r[i][j]);
      else
        printf("#");
    printf("\n");
  }
  return 0;
}
