#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define forn(a,b,c) for(int a=b;a<=c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
const int N=12;
const int NSQ=105;
int n,m,sz;
char mat[N][N],mat1[N][N];
int dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
//50 bodova plis
vector<int> g[NSQ];
void dfs1(int x,int y,int currx,int curry,int dir){
    if(mat[currx][curry]!='.')return;
    g[m*x+y].pb(m*currx+curry);
    dfs1(x,y,currx+dx[dir],curry+dy[dir],dir);
}
void dfs(int x,int y){
    dfs1(x,y,x+dx[0],y+dy[0],0);
    dfs1(x,y,x+dx[1],y+dy[1],1);
    dfs1(x,y,x+dx[2],y+dy[2],2);
    dfs1(x,y,x+dx[3],y+dy[3],3);
}
pii coords(int pos){
    return pii(pos/m,pos%m);
}
void print(){
    forn(i,0,n-1){
        forn(j,0,m-1){
            printf("%c",mat1[i][j]);
        }
        printf("\n");
    }
    //printf("\n");
}
bool ok(int x,int y){
    if(x>=0&&y>=0&&x<n&&y<m){
        return true;
    }
    return false;
}
int check2(int x,int y){
    int cnt=0;
    forn(i,0,3){
        if(ok(x+dx[i],y+dy[i])&&mat1[x+dx[i]][y+dy[i]]=='C'){
            cnt++;
        }
    }
    return cnt;
}
bool check(){
    forn(i,0,n-1){
        forn(j,0,m-1){
            /*if(mat1[i][j]=='.'){
                bool b1=false;
                for(auto&y:g[m*i+j]){
                    pii c1=coords(y);
                    if(mat1[c1.f][c1.s]=='C')
                        b1=true;
                }
                if(!b1)
                    return 0;
            }*/
            if(mat1[i][j]=='0'||mat1[i][j]=='1'||mat1[i][j]=='2'||mat1[i][j]=='3'||mat1[i][j]=='4'){
                //printf("da za %d %d mat1[i][j]:%c\n",i,j,mat1[i][j]);
                int cnt1=mat1[i][j]-'0';
                int cnt2=check2(i,j);
                //printf("cnt1:%d cnt2:%d\n",cnt1,cnt2);
                if(cnt1!=cnt2){
                    return 0;
                }
            }
        }
    }
    return 1;
}
void s1(){
    forn(i,0,n-1){
        forn(j,0,m-1){
            if(i==j){
                printf("C");
            }
            else{
                printf(".");
            }
        }
        printf("\n");
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    sz=n*m;
    bool emp=true;
    forn(i,0,n-1){
        forn(j,0,m-1){
            scanf(" %c",&mat[i][j]);
            if(mat[i][j]!='.')emp=false;
        }
    }
    if(emp){
        s1();
        return 0;
    }
    forn(i,0,n-1){
        forn(j,0,m-1){
            if(mat[i][j]=='.'){
                dfs(i,j);
            }
        }
    }
    /*forn(i,0,sz-1){
        printf("g[%d]:\n",i);
        for(auto& x:g[i]){
            printf("%d ",x);
        }
        printf("\n");
    }*/
    forn(i,0,(1<<sz)-1){
        bool b=true;
        forn(j,0,sz-1){
            pii c=coords(j);
            if(i&(1<<j)){
                if(mat[c.f][c.s]!='.'){
                    b=false;
                    break;
                }
                for(auto&x:g[j]){
                    if(i&(1<<x)){
                        b=false;
                        break;
                    }
                }
            }
            else if(mat[c.f][c.s]=='.'){
                bool b1=false;
                for(auto&y:g[j]){
                    if(i&(1<<y))
                        b1=true;
                }
                if(!b1){
                    b=false;
                    break;
                }
            }
        }
        if(!b)continue;
        forn(j,0,sz-1){
            pii c=coords(j);
            if(i&(1<<j)){
                mat1[c.f][c.s]='C';
            }
            else{
                mat1[c.f][c.s]=mat[c.f][c.s];
            }
        }
      //  printf("i:%d\n",i);
        //print();
        if(check()){
            print();
            return 0;
          //  printf("da\n");
        }
    }
    printf("-1\n");
    return 0;
}