#include <bits/stdc++.h>
using namespace std;
inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a < b ? a : b; }
vector<string> g;
int n, m;
int main() {
  cin >> n >> m;
  g.clear();
  g.push_back(string(m + 2, '#'));
  string s;
  for (int i(1); i <= (n); ++i) {
    g.push_back("#");
    cin >> s;
    s += '#';
    g[i] += s;
  }
  g.push_back(string(m + 2, '#'));
  for (int i(1); i <= (n); ++i)
    for (int j(1); j <= (m); ++j)
      if (g[i][j] == '.') {
        char ch('0' + ((i % 3) + (j % 3) * 3) % 10);
        g[i][j] = ch;
        if (g[i][j + 1] == '.')
          g[i][j + 1] = ch;
        else if (g[i + 1][j] == '.')
          g[i + 1][j] = ch;
        else {
          if (g[i][j - 1] != '#')
            g[i][j] = g[i][j - 1];
          else if (g[i - 1][j] != '#')
            g[i][j] = g[i - 1][j];
          else if (g[i][j + 1] != '#')
            g[i][j] = g[i][j + 1];
          else {
            puts("-1");
            return 0;
          }
        }
      }
  for (int i(1); i <= (n); ++i)
    for (int j(1); j <= (m); ++j)
      if (j == m)
        printf("%c\n", g[i][j]);
      else
        printf("%c", g[i][j]);
  return 0;
}
