#include <bits/stdc++.h>
using namespace std;
int i, j, n, m, color;
char a[1005][1005];
int main() {
  cin >> n >> m;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++)
    for (j = 0; j < m - 1; j++)
      if (a[i][j] == '.' && a[i][j + 1] == '.')
        a[i][j] = a[i][j + 1] = '0' + i % 3 * 3 + (j + (i + j) % 2) % 3;
  for (i = 0; i < n - 1; i++)
    for (j = 0; j < m; j++)
      if (a[i][j] == '.' && a[i + 1][j] == '.')
        a[i][j] = a[i + 1][j] = '0' + (i + (i + j) % 2) % 3 * 3 + j % 3;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (a[i][j] == '.') {
        if (i && a[i - 1][j] != '#')
          a[i][j] = a[i - 1][j];
        else if (j && a[i][j - 1] != '#')
          a[i][j] = a[i][j - 1];
        else if (i + 1 < n && a[i + 1][j] != '#')
          a[i][j] = a[i + 1][j];
        else if (j + 1 < m && a[i][j + 1] != '#')
          a[i][j] = a[i][j + 1];
        else {
          puts("-1");
          return 0;
        }
      }
  for (i = 0; i < n; i++) puts(a[i]);
  return 0;
}
