#include <bits/stdc++.h>
using namespace std;
int N;
char MAT[1010][1010];
int ID[1010][1010];
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
bool VIS[1010][1010];
vector<pair<int, int> > V[1000000];
bool outb(int i, int j, int R, int C) {
  return i < 0 || j < 0 || i >= R || j >= C;
}
int main() {
  int R, C;
  scanf("%d %d", &R, &C);
  for (int i = 0; i < R; ++i) scanf("%s", MAT[i]);
  int idx = 1;
  for (int i = 0; i < R; ++i) {
    for (int j = 0; j < C; ++j) {
      if (ID[i][j] || MAT[i][j] == '#') continue;
      for (int k = 0; k < 4; ++k) {
        int ni = i + dx[k];
        int nj = j + dy[k];
        if (outb(ni, nj, R, C)) continue;
        if (ID[ni][nj] || MAT[ni][nj] == '#') continue;
        ID[i][j] = idx;
        ID[ni][nj] = idx;
        V[idx].push_back(pair<int, int>(i, j));
        V[idx].push_back(pair<int, int>(ni, nj));
        ++idx;
        break;
      }
    }
  }
  for (int i = 0; i < R; ++i) {
    for (int j = 0; j < C; ++j) {
      if (ID[i][j] || MAT[i][j] == '#') continue;
      for (int k = 0; k < 4; ++k) {
        int ni = i + dx[k];
        int nj = j + dy[k];
        if (outb(ni, nj, R, C)) continue;
        if (MAT[ni][nj] == '#') continue;
        ID[i][j] = ID[ni][nj];
        V[ID[i][j]].push_back(pair<int, int>(i, j));
      }
    }
  }
  for (int i = 1; i < idx; ++i) {
    bool used[] = {false, false, false, false, false, false, false,
                   false, false, false, false, false, false};
    for (int j = 0; j < V[i].size(); ++j) {
      for (int k = 0; k < 4; ++k) {
        int ni = V[i][j].first + dx[k];
        int nj = V[i][j].second + dy[k];
        if (outb(ni, nj, R, C)) continue;
        if (MAT[ni][nj] == '#' || MAT[ni][nj] == '.') continue;
        used[MAT[ni][nj] - '0'] = true;
      }
    }
    char c = 0;
    for (int j = 0; j < 10; ++j)
      if (!used[j]) {
        c = j;
        break;
      }
    for (int j = 0; j < V[i].size(); ++j) {
      MAT[V[i][j].first][V[i][j].second] = char(c + '0');
    }
  }
  for (int i = 0; i < R; ++i)
    for (int j = 0; j < C; ++j)
      if (MAT[i][j] == '.') {
        printf("-1\n");
        return 0;
      }
  for (int i = 0; i < R; ++i) printf("%s\n", MAT[i]);
  return 0;
}
