#include <iostream>
#include <queue>
using namespace std;

int main()
{
    int N,M;
    int i,j, x , y, resenje, mogucnosti;
    cin >> N >> M;
    char matrica[N][M];
    pair<int,pair<int,int>> trenutna;
    priority_queue<pair<int,pair<int,int>>> kockice;
    for(i = 0; i < N; i++){
        for(j = 0; j < M; j++){
           cin >> matrica[i][j];
           if((int)matrica[i][j] == 48){
                trenutna.first = 5;
                trenutna.second.first = i;
                trenutna.second.second = j;
                kockice.push(trenutna);
           }
           else if((int)matrica[i][j] > 48 && (int)matrica[i][j] < 53){
                trenutna.first = matrica[i][j] - 48;
                trenutna.second.first = i;
                trenutna.second.second = j;
                kockice.push(trenutna);
           }
        }
    }
    while(!kockice.empty()){
        trenutna = kockice.top();
        x = trenutna.second.first;
        y = trenutna.second.second;
        if(matrica[x][y] == '0'){
            if(matrica[x-1][y] == '.' && x > 0) matrica[x-1][y] = '/';
            if(matrica[x+1][y] == '.' && x < N-1) matrica[x+1][y] = '/';
            if(matrica[x][y-1] == '.' && y > 0) matrica[x][y-1] = '/';
            if(matrica[x][y+1] == '.' && y < M-1) matrica[x][y+1] = '/';
            kockice.pop();
        }
        else if(matrica[x][y] == '4'){
            if(matrica[x-1][y] == '.' || matrica[x-1][y] == 'C'){
                matrica[x-1][y] = 'C';
                for(i = x-1; i < N; i++){
                    if(matrica[i+1][y] != '.' || matrica[i+1][y] != '/')
                        break;
                    else matrica[i+1][y] = '/';
                }
                for(i = x-1; i > 0; i--){
                    if(matrica[i-1][y] != '.' || matrica[i-1][y] != '/')
                        break;
                    else matrica[i-1][y] = '/';
                }
                for(i = y; i < M; i++){
                    if(matrica[x-1][i+1] != '.' || matrica[x-1][i+1] != '/')
                        break;
                    else matrica[x-1][i+1] = '/';
                }
                for(i = y; i > 0; i--){
                    if(matrica[x-1][i-1] != '.' || matrica[x-1][i-1] != '/')
                        break;
                    else matrica[x-1][i-1] = '/';
                }
            }
            else resenje = -1;
            if(matrica[x+1][y] == '.' || matrica[x+1][y] == 'C'){
                matrica[x+1][y] = 'C';
                for(i = x+1; i < N; i++){
                    if(matrica[i+1][y] != '.' || matrica[i+1][y] != '/')
                        break;
                    else matrica[i+1][y] = '/';
                }
                for(i = x+1; i > 0; i--){
                    if(matrica[i-1][y] != '.' || matrica[i-1][y] != '/')
                        break;
                    else matrica[i-1][y] = '/';
                }
                for(i = y; i < M; i++){
                    if(matrica[x+1][i+1] != '.' || matrica[x+1][i+1] != '/')
                        break;
                    else matrica[x+1][i+1] = '/';
                }
                for(i = y; i > 0; i--){
                    if(matrica[x+1][i-1] != '.' || matrica[x+1][i-1] != '/')
                        break;
                    else matrica[x+1][i-1] = '/';
                }
            }
            else resenje = -1;
            if(matrica[x][y-1] == '.' || matrica[x][y-1] == 'C'){
                matrica[x][y-1] = 'C';
                for(i = x; i < N; i++){
                    if(matrica[i+1][y-1] != '.' || matrica[i+1][y-1] != '/')
                        break;
                    else matrica[i+1][y-1] = '/';
                }
                for(i = x; i > 0; i--){
                    if(matrica[i-1][y-1] != '.' || matrica[x-1][y] != '/')
                        break;
                    else matrica[i-1][y-1] = '/';
                }
                for(i = y-1; i < M; i++){
                    if(matrica[x][i+1] != '.' || matrica[x][i+1] != '/')
                        break;
                    else matrica[x][i+1] = '/';
                }
                for(i = y-1; i > 0; i--){
                    if(matrica[x][i-1] != '.' || matrica[x][i-1] != '/')
                        break;
                    else matrica[x][i-1] = '/';
                }
            }
            else resenje = -1;
            if(matrica[x][y+1] == '.'|| matrica[x][y+1] == 'C'){
                matrica[x][y+1] = 'C';
                for(i = x; i < N; i++){
                    if(matrica[i+1][y+1] != '.' || matrica[i+1][y+1] != '/')
                        break;
                    else matrica[i+1][y+1] = '/';
                }
                for(i = x; i > 0; i--){
                    if(matrica[i-1][y+1] != '.' || matrica[i-1][y+1] != '/')
                        break;
                    else matrica[i-1][y+1] = '/';
                }
                for(i = y+1; i < M; i++){
                    if(matrica[x][i+1] != '.' || matrica[x][i+1] != '/')
                        break;
                    else matrica[x][i+1] = '/';
                }
                for(i = y+1; i > 0; i--){
                    if(matrica[x][i-1] != '.' || matrica[x][i-1] != '/')
                        break;
                    else matrica[x][i-1] = '/';
                }
            }
            else resenje = -1;
            kockice.pop();
        }
        else{
            mogucnosti = 0;
            if(matrica[x-1][y] == '.' || matrica[x-1][y] == 'C') mogucnosti++;
            if(matrica[x+1][y] == '.' || matrica[x+1][y] == 'C') mogucnosti++;
            if(matrica[x][y-1] == '.' || matrica[x][y-1] == 'C') mogucnosti++;
            if(matrica[x][y+1] == '.' || matrica[x][y+1] == 'C') mogucnosti++;

            if(mogucnosti < (int)matrica[x][y]-48){
                resenje = -1;
                while(!kockice.empty())
                    kockice.pop();
            }
            else if(mogucnosti > (int)matrica[x][y]-48){
                kockice.pop();
                trenutna.first -= 5;
                kockice.push(trenutna);
            }
            else{
                if(matrica[x-1][y] == '.'){
                    matrica[x-1][y] = 'C';
                    for(i = x-1; i < N; i++){
                        if(matrica[i+1][y] != '.' || matrica[i+1][y] != '/')
                            break;
                        else matrica[i+1][y] = '/';
                    }
                    for(i = x-1; i > 0; i--){
                        if(matrica[i-1][y] != '.' || matrica[i-1][y] != '/')
                            break;
                        else matrica[i-1][y] = '/';
                    }
                    for(i = y; i < M; i++){
                        if(matrica[x-1][i+1] != '.' || matrica[x-1][i+1] != '/')
                            break;
                        else matrica[x-1][i+1] = '/';
                    }
                    for(i = y; i > 0; i--){
                        if(matrica[x-1][i-1] != '.' || matrica[x-1][i-1] != '/')
                            break;
                            else matrica[x-1][i-1] = '/';
                    }
                }
                if(matrica[x+1][y] == '.'){
                    matrica[x+1][y] = 'C';
                    for(i = x+1; i < N; i++){
                        if(matrica[i+1][y] != '.' || matrica[i+1][y] != '/')
                            break;
                        else matrica[i+1][y] = '/';
                    }
                    for(i = x+1; i > 0; i--){
                        if(matrica[i-1][y] != '.' || matrica[i-1][y] != '/')
                            break;
                        else matrica[i-1][y] = '/';
                    }
                    for(i = y; i < M; i++){
                        if(matrica[x+1][i+1] != '.' || matrica[x+1][i+1] != '/')
                            break;
                        else matrica[x+1][i+1] = '/';
                    }
                    for(i = y; i > 0; i--){
                        if(matrica[x+1][i-1] != '.' || matrica[x+1][i-1] != '/')
                            break;
                            else matrica[x+1][i-1] = '/';
                    }
                }
                if(matrica[x][y-1] == '.'){
                    matrica[x][y-1] = 'C';
                    for(i = x; i < N; i++){
                        if(matrica[i+1][y-1] != '.' || matrica[i+1][y-1] != '/')
                            break;
                        else matrica[i+1][y] = '/';
                    }
                    for(i = x; i > 0; i--){
                        if(matrica[i-1][y-1] != '.' || matrica[i-1][y-1] != '/')
                            break;
                        else matrica[i-1][y-1] = '/';
                    }
                    for(i = y-1; i < M; i++){
                        if(matrica[x][i+1] != '.' || matrica[x][i+1] != '/')
                            break;
                        else matrica[x][i+1] = '/';
                    }
                    for(i = y-1; i > 0; i--){
                        if(matrica[x][i-1] != '.' || matrica[x][i-1] != '/')
                            break;
                        else matrica[x][i-1] = '/';
                    }
                }
                if(matrica[x][y+1] == '.'){
                    matrica[x][y+1] = 'C';
                    for(i = x; i < N; i++){
                        if(matrica[i+1][y+1] != '.' || matrica[i+1][y+1] != '/')
                            break;
                        else matrica[i+1][y+1] = '/';
                    }
                    for(i = x; i > 0; i--){
                        if(matrica[i-1][y+1] != '.' || matrica[i-1][y+1] != '/')
                            break;
                        else matrica[i-1][y+1] = '/';
                    }
                    for(i = y+1; i < M; i++){
                        if(matrica[x][i+1] != '.' || matrica[x][i+1] != '/')
                            break;
                        else matrica[x][i+1] = '/';
                    }
                    for(i = y+1; i > 0; i--){
                        if(matrica[x][i-1] != '.' || matrica[x][i-1] != '/')
                            break;
                        else matrica[x][i-1] = '/';
                    }
                }
                kockice.pop();
            }

        }
        for(i = 0; i < N; i++){
            for(j = 0; j < M; j++){
                cout << matrica[i][j];
            }
            cout << endl;
        }
    }


    if(resenje == -1) cout << -1;
    else{
        for(i = 0; i < N; i++){
            for(j = 0; j < M; j++){
                cout << matrica[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}