#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 100;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
struct edge {
  int x, y, xx, yy;
  edge() {}
  edge(int xxx, int yyy, int xxxx, int yyyy) {
    x = xxx;
    y = yyy;
    xx = xxxx;
    yy = yyyy;
  }
};
int n, m, ted;
char a[maxn][maxn];
int mark[maxn][maxn];
vector<pair<int, int> > v[2 * maxn * maxn], vv[7];
vector<edge> e[maxn * maxn];
bool vis[20], see[maxn][maxn];
void dfs(int v1, int v2, int sz, int com) {
  see[v1][v2] = true;
  vv[com].push_back(make_pair(v1, v2));
  for (int i = 0; i < e[sz].size(); i++)
    if (vis[i]) {
      if (e[sz][i].x == v1 && e[sz][i].y == v2)
        if (!see[e[sz][i].xx][e[sz][i].yy])
          dfs(e[sz][i].xx, e[sz][i].yy, sz, com);
      if (e[sz][i].xx == v1 && e[sz][i].yy == v2)
        if (!see[e[sz][i].x][e[sz][i].y]) dfs(e[sz][i].x, e[sz][i].y, sz, com);
    }
}
bool check(int sz) {
  int cnt = 0;
  for (int i = 0; i <= 6; i++) vv[i].clear();
  for (int i = 0; i < v[sz].size(); i++)
    if (!see[v[sz][i].first][v[sz][i].second])
      dfs(v[sz][i].first, v[sz][i].second, sz, cnt++);
  for (int i = 0; i < v[sz].size(); i++)
    see[v[sz][i].first][v[sz][i].second] = false;
  int num[7];
  memset(num, 0, sizeof num);
  for (int i = 0; i < cnt; i++) num[vv[i].size()]++;
  if (v[sz].size() == 6) {
    if ((num[2] == 1 && num[4] == 1) || num[2] == 3 || (num[3] == 2)) {
      v[sz].clear();
      for (int i = 0; i < cnt; i++) {
        ted++;
        for (int j = 0; j < v[i].size(); j++)
          mark[v[i][j].first][v[i][j].second] = ted;
        v[ted] == vv[i];
      }
      return true;
    }
  } else if (v[sz].size() == 5) {
    if (num[2] == 1 && num[3] == 1) {
      v[sz].clear();
      for (int i = 0; i < cnt; i++) {
        ted++;
        for (int j = 0; j < v[i].size(); j++)
          mark[v[i][j].first][v[i][j].second] = ted;
        v[ted] = vv[i];
      }
      return true;
    }
  } else if (v[sz].size() == 4)
    if (num[2] == 2) {
      v[sz].clear();
      for (int i = 0; i < cnt; i++) {
        ted++;
        for (int j = 0; j < v[i].size(); j++)
          mark[v[i][j].first][v[i][j].second] = ted;
        v[ted] = vv[i];
      }
      return true;
    }
}
bool bomb = false;
void bt(int step, int sz) {
  if (step == v[sz].size()) {
    if (!bomb) bomb = check(sz);
    return;
  }
  bt(step + 1, sz);
  vis[step] = true;
  bt(step + 1, sz);
  vis[step] = false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] == '.' && !mark[i][j]) {
        int cnt1 = 0;
        for (int l = 0; l < 4; l++) {
          int x = i + dx[l], y = j + dy[l];
          if (a[x][y] == '.') cnt1++;
          if (!mark[i][j] && a[x][y] == '.' && !mark[x][y]) {
            ted++;
            v[ted].push_back(make_pair(i, j));
            v[ted].push_back(make_pair(x, y));
            e[ted].push_back(edge(i, j, x, y));
            mark[i][j] = ted;
            mark[x][y] = ted;
          }
        }
        if (cnt1 == 0) {
          cout << "-1" << endl;
          return 0;
        }
      }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (a[i][j] == '.' && !mark[i][j])
        for (int l = 0; l < 4; l++)
          if (!mark[i][j] && mark[i + dx[l]][j + dy[l]]) {
            mark[i][j] = mark[i + dx[l]][j + dy[l]];
            e[mark[i][j]].push_back(edge(i, j, i + dx[l], j + dy[l]));
            v[mark[i][j]].push_back(make_pair(i, j));
          }
  for (int i = 1; i <= ted; i++)
    if (v[i].size() >= 4) bt(0, i);
  for (int i = 1; i <= ted; i++)
    if (v[i].size()) {
      bool col[10];
      memset(col, 0, sizeof col);
      int com = mark[v[i][0].first][v[i][0].second];
      for (int j = 0; j < v[i].size(); j++)
        for (int l = 0; l < 4; l++) {
          int v1 = dx[l] + v[i][j].first, v2 = dy[l] + v[i][j].second;
          if (a[v1][v2] >= '0' && a[v1][v2] <= '9') col[a[v1][v2] - '0'] = true;
        }
      for (int j = 0; j <= 9; j++)
        if (!col[j]) {
          for (int l = 0; l < v[i].size(); l++)
            a[v[i][l].first][v[i][l].second] = char('0' + j);
          break;
        }
    }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cout << a[i][j];
    cout << endl;
  }
  return 0;
}
