#include <bits/stdc++.h>
using namespace std;
char buf[1005][1005];
int ans[1005][1005];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int cur = 1;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> buf[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (buf[i][j] == '.' && buf[i][j + 1] == '.' && !ans[i][j]) {
        ans[i][j] = ans[i][j + 1] = cur++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (buf[i][j] == '.' && buf[i + 1][j] == '.' && !ans[i][j] &&
          !ans[i + 1][j]) {
        ans[i][j] = ans[i + 1][j] = cur++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (buf[i][j] == '.' && !ans[i][j]) {
        bool good = false;
        for (int k = 0; k < 4; k++) {
          int nx = i + dx[k], ny = j + dy[k];
          if (nx >= 0 && nx < n && ny >= 0 && ny < m && ans[nx][ny]) {
            ans[i][j] = ans[nx][ny];
            good = true;
            break;
          }
        }
        if (!good) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (buf[i][j] == '.') {
        bool can[10] = {};
        set<pair<int, int> > S;
        queue<pair<int, int> > Q;
        Q.push(make_pair(i, j));
        buf[i][j] = '#';
        while (!Q.empty()) {
          pair<int, int> par = Q.front();
          S.insert(par);
          Q.pop();
          for (int k = 0; k < 4; k++) {
            int nx = par.first + dx[k];
            int ny = par.second + dy[k];
            if (nx < n && nx >= 0 && ny < m && ny >= 0) {
              if (buf[nx][ny] != '#') {
                if (ans[i][j] != ans[nx][ny]) {
                  if (buf[nx][ny] != '.') {
                    can[buf[nx][ny] - '0'] = true;
                  }
                } else {
                  Q.push(make_pair(nx, ny));
                  buf[nx][ny] = '#';
                }
              }
            }
          }
        }
        int col = 0;
        for (col = 0; can[col]; col++)
          ;
        for (set<pair<int, int> >::iterator it = S.begin(); it != S.end();
             ++it) {
          buf[it->first][it->second] = col + '0';
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << buf[i] << endl;
  }
  return 0;
}
