#include <bits/stdc++.h>

#define MAXN 15
using namespace std;
int tabla[MAXN][MAXN];
int n,m;

void pisi(int tabla[MAXN][MAXN]){
    for (int i = 1; i <=n; i++)
    {
        for (int j = 1; j <=m; j++){
            if(tabla[i][j]==-6)
                cout<<'#';
            else if(tabla[i][j]==-1)
                cout<<4;
            else if(tabla[i][j]==-2)
                cout<<3;
            else if(tabla[i][j]==-3)
                cout<<2;
            else if(tabla[i][j]==-4)
                cout<<1;
            else if(tabla[i][j]==-5)
                cout<<0;
            else if(tabla[i][j]==-10)
                cout<<'C';
            else
                cout<<'.';
        }
        printf("\n");
    }
}
int brojpopunjenih(int tabla[MAXN][MAXN], int i, int j){
    int res=0;
    if(tabla[i-1][j]==-10)
        res++;
    if(tabla[i+1][j]==-10)
        res++;
    if(tabla[i][j-1]==-10)
        res++;
    if(tabla[i][j+1]==-10)
        res++;
    return res;
}
bool nestonapada(int tabla[MAXN][MAXN], int ip, int jp){
    int i,j;
    //levo
    for (j = jp-1; j >0; j--){
        if(tabla[ip][j]==-10)
            return true;
        if(tabla[ip][j]!=0)
            break;
    }
    //desno
    for (j = jp+1; j <=m; j++){
        if(tabla[ip][j]==-10)
            return true;
        if(tabla[ip][j]!=0)
            break;
    }
    //gore
    for (i = ip-1; i >0; i--){
        if(tabla[i][jp]==-10)
            return true;
        if(tabla[i][jp]!=0)
            break;
    }
    //dole
     for (i = ip+1; i <=n; i++){
        if(tabla[i][jp]==-10)
            return true;
        if(tabla[i][jp]!=0)
            break;
    }
    return false;
}
bool tablaBezbedna(int tabla[MAXN][MAXN]){
    int i,j;
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            if(tabla[i][j]==-10 || tabla[i][j]==-6)
                continue;
            if(tabla[i][j]==-5 && brojpopunjenih(tabla,i,j)!=0){
                return false;
            }
            if(tabla[i][j]==-4 && brojpopunjenih(tabla,i,j)!=1){
                return false;
            }
            if(tabla[i][j]==-3 && brojpopunjenih(tabla,i,j)!=2){
                return false;
            }
            if(tabla[i][j]==-2 && brojpopunjenih(tabla,i,j)!=3){
                return false;
            }
            if(tabla[i][j]==-1 && brojpopunjenih(tabla,i,j)!=4){
                return false;
            }
            if(tabla[i][j]==-0 && !nestonapada(tabla,i,j)){
                return false;
            }
        }
    }
    return true;
}
bool poljeBezbedno(int tabla[MAXN][MAXN],int ip, int jp)
{
    int i, j;
    //polje mora biti nula
    if(tabla[ip][jp]!=0)
        return false;
    //mora zadovoljavati uslove okolo
    if(tabla[ip-1][jp]==-5)
        return false;
     if(tabla[ip+1][jp]==-5)
        return false;
    if(tabla[ip][jp-1]==-5)
        return false;
    if(tabla[ip][jp+1]==-5)
        return false;
    //levo
    for (j = jp-1; j >0; j--){
        if(tabla[ip][j]==-10)
            return false;
        if(tabla[ip][j]!=0)
            break;
    }
    //desno
    for (j = jp+1; j <=m; j++){
        if(tabla[ip][j]==-10)
            return false;
        if(tabla[ip][j]!=0)
            break;
    }
    //gore
    for (i = ip-1; i >0; i--){
        if(tabla[i][jp]==-10)
            return false;
        if(tabla[i][jp]!=0)
            break;
    }
    //dole
     for (i = ip+1; i <=n; i++){
        if(tabla[i][jp]==-10)
            return false;
        if(tabla[i][jp]!=0)
            break;
    }
    return true;
}
bool resi(int tabla[MAXN][MAXN], int i, int j) {
    /* base case: If all queens are placed
      then return true */
    if (i > n){
        if(tablaBezbedna(tabla))
            return true;
        return false;
    }
    if(!poljeBezbedno(tabla,i,j)){
        j++;
        if(j>m){
            j=1;
            i++;
        }
        resi(tabla,i,j);
    }else{
        tabla[i][j]=-10;
        int pomi=i;
        int pomj=j;
        j++;
        if(j>m){
            j=1;
            i++;
        }
        if(resi(tabla,i,j))
            return true;
        tabla[pomi][pomj]=0;
        return resi(tabla,i,j);
    }
}
void resipraznu(int tabla[MAXN][MAXN]){
    int i;
    if(n>m){
        for(i=1;i<=m;i++)
            tabla[i][i]=-10;
    }else{
        for(i=1;i<=n;i++)
            tabla[i][i]=-10;
    }
}
int main()
{
    int k=0;
    int i,j;
    char c;
    string s;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            cin>>c;
            if(c=='#')
                tabla[i][j]=-6;
            else if(c=='4')
                tabla[i][j]=-1;
            else if(c=='3')
                tabla[i][j]=-2;
            else if(c=='2')
                tabla[i][j]=-3;
            else if(c=='1')
                tabla[i][j]=-4;
            else if(c=='0')
                tabla[i][j]=-5;
            else
                tabla[i][j]=0;
            if(c!='.')
                k++;
        }
    }
    if(k==0){
        resipraznu(tabla);
        pisi(tabla);
    }
    else{
        if(resi(tabla,1,1))
            pisi(tabla);
        else
            cout << "-1";
    }
    return 0;
}