#include <iostream>
#include <vector>
#include <stdlib.h>

using namespace std;

int mat[12][12]={};
struct kocka{
    int i;
    int j;
    int v;
};
vector <kocka> kockice;
int a, b; char c;

void printm(){
    for(int i=1;i<=a;i++){
        for(int j=1;j<=b;j++)cout<<mat[i][j];
        cout<<endl;
    }cout<<endl;
}

int one(int x){
    if(x)return 1;
    return 0;
}

bool resiGa(int x){
    bool changed=false;
    for(int ah=0;ah<kockice.size();ah++){
        if(kockice[ah].v==x){
            if(one(mat[kockice[ah].i][kockice[ah].j+1])+one(mat[kockice[ah].i+1][kockice[ah].j])+one(mat[kockice[ah].i][kockice[ah].j-1])+one(mat[kockice[ah].i-1][kockice[ah].j]) > 4-x){
                cout<<-1<<endl;
                exit(1);
            }
            else if(one(mat[kockice[ah].i][kockice[ah].j+1])+one(mat[kockice[ah].i+1][kockice[ah].j])+one(mat[kockice[ah].i][kockice[ah].j-1])+one(mat[kockice[ah].i-1][kockice[ah].j]) == 4-x){
                for(int i=kockice[ah].i+1;i<=a and (mat[i][kockice[ah].j]==0 or mat[i][kockice[ah].j]==7);i++)mat[i][kockice[ah].j]=7;
                for(int i=kockice[ah].i-1;i>=1 and (mat[i][kockice[ah].j]==0 or mat[i][kockice[ah].j]==7);i--)mat[i][kockice[ah].j]=7;
                for(int j=kockice[ah].j+1;j<=b and (mat[kockice[ah].i][j]==0 or mat[kockice[ah].i][j]==7);j++)mat[kockice[ah].i][j]=7;
                for(int j=kockice[ah].j-1;j>=1 and (mat[kockice[ah].i][j]==0 or mat[kockice[ah].i][j]==7);j--)mat[kockice[ah].i][j]=7;
                mat[kockice[ah].i][kockice[ah].j+1]=8;
                mat[kockice[ah].i+1][kockice[ah].j]=8;
                mat[kockice[ah].i][kockice[ah].j-1]=8;
                mat[kockice[ah].i-1][kockice[ah].j]=8;
                kockice.erase(kockice.begin()+ah);
                ah--;   
                changed=true;
                //cout<<"> "<<x<<endl;
            }
        }
    }
    //cout<<kockice.size()<<" "<<x<<endl;printm();
    return changed;
}

int main() {
    cin>>a>>b;
    //for(int i=1;i<=a;i++){mat[0][i]=7;mat[a+1][i]=7;}
    //for(int i=1;i<=b;i++){mat[i][0]=7;mat[i][b+1]=7;}
    bool empty=true;
    for(int i=1;i<=a;i++){
        for(int j=1;j<=b;j++){
            cin>>c;
            if(c=='0'){empty=false;mat[i][j]=1;kockice.push_back({i,j,0});}
            if(c=='1'){empty=false;mat[i][j]=2;kockice.push_back({i,j,1});}
            if(c=='2'){empty=false;mat[i][j]=3;kockice.push_back({i,j,2});}
            if(c=='3'){empty=false;mat[i][j]=4;kockice.push_back({i,j,3});}
            if(c=='4'){empty=false;mat[i][j]=5;kockice.push_back({i,j,4});}
            if(c=='#'){empty=false;mat[i][j]=6;}
        }
    }
    
    if(empty){
        for(int i = 1;  i <= a;i++){
            for(int j=1;j<=b;j++){
                if(i==j)cout<<"C";
                else cout<<".";
            }
            cout<<endl;
        }
        return 0;
    }
    
    
    return 0;

}
/*
5 6
.#01.1
2.....
0.....
......
#...2.


5 6
0.....
......
..4...
......
......


5 6
.#01.1
2.....
0.....
......
#...2.

*/