#include <bits/stdc++.h>
using namespace std;
long long labs(long long a) { return a < 0 ? (-a) : a; }
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
template <typename T>
struct Point {
  T x, y;
  Point() {}
  Point(T xx, T yy) : x(xx), y(yy) {}
};
template <typename T>
bool operator<(const Point<T> &p1, const Point<T> &p2) {
  return p1.x < p2.x || p1.x == p2.x && p1.y < p2.y;
}
const int MAXN = 1005;
char mas[MAXN][MAXN];
int was[MAXN][MAXN];
const int di[] = {0, 0, 1, -1};
const int dj[] = {1, -1, 0, 0};
int n, m;
bool InBorder(int i, int j) { return i >= 0 && j >= 0 && i < n && j < m; }
bool mask[10];
void dfs(int i, int j, int col) {
  if (!InBorder(i, j) || mas[i][j] == '#' || mas[i][j] == '-') return;
  if (isdigit(mas[i][j])) {
    mask[mas[i][j] - '0'] = 1;
  }
  if (was[i][j] != col) return;
  mas[i][j] = '-';
  for (int(k) = 0; (k) < (4); (k)++) {
    dfs(i + di[k], j + dj[k], col);
  }
}
void dfs1(int i, int j, char nc) {
  if (!InBorder(i, j) || mas[i][j] != '-') return;
  mas[i][j] = nc;
  for (int(k) = 0; (k) < (4); (k)++) {
    dfs1(i + di[k], j + dj[k], nc);
  }
}
void Solve() {
  for (int(i) = 0; (i) < (n); (i)++) {
    for (int(j) = 0; (j) < (m); (j)++) {
      if (mas[i][j] == '.') {
        memset((mask), 0, sizeof(mask));
        dfs(i, j, was[i][j]);
        char col = '9';
        for (int(k) = 0; (k) < (10); (k)++) {
          if (!mask[k]) {
            col = k + '0';
            break;
          }
        }
        dfs1(i, j, col);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int(i) = 0; (i) < (n); (i)++) {
    for (int(j) = 0; (j) < (m); (j)++) {
      cin >> mas[i][j];
    }
  }
  memset((was), 0, sizeof(was));
  int col = 1;
  for (int(i) = 0; (i) < (n); (i)++) {
    for (int(j) = 0; (j) < (m - 1); (j)++) {
      if (mas[i][j] == '.' && mas[i][j + 1] == '.' && was[i][j] == 0 &&
          was[i][j + 1] == 0) {
        was[i][j] = was[i][j + 1] = col++;
      }
    }
  }
  for (int(i) = 0; (i) < (n - 1); (i)++) {
    for (int(j) = 0; (j) < (m); (j)++) {
      if (mas[i][j] == '.' && mas[i + 1][j] == '.' && was[i][j] == 0 &&
          was[i + 1][j] == 0) {
        was[i][j] = was[i + 1][j] = col++;
      }
    }
  }
  for (int(i) = 0; (i) < (n); (i)++) {
    for (int(j) = 0; (j) < (m); (j)++) {
      if (mas[i][j] == '.' && was[i][j] == 0) {
        bool ok = 0;
        for (int(k) = 0; (k) < (4); (k)++) {
          if (InBorder(i + di[k], j + dj[k]) &&
              mas[i + di[k]][j + dj[k]] == '.') {
            was[i][j] = was[i + di[k]][j + dj[k]];
            ok = true;
            break;
          }
        }
        if (!ok) {
          cout << -1;
          return 0;
        }
      }
    }
  }
  Solve();
  for (int(i) = 0; (i) < (n); (i)++) {
    for (int(j) = 0; (j) < (m); (j)++) {
      cout << mas[i][j];
    }
    cout << endl;
  }
  return 0;
}
