#include <iostream>
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;a++)
#define Ford(a,b,c) for(int a=b;a>=c;a--)
#define ll long long
#define pb push_back
const int MAX=1e2+2;
using namespace std;

int levi[MAX][MAX],desni[MAX][MAX],gornji[MAX][MAX],donji[MAX][MAX];
int n,m,preg,r=0;

bool ok,good[MAX][MAX];
char s[MAX],c[MAX][MAX],b[MAX][MAX],zab[MAX][MAX];int z=0,f=0;
vector<pair< pair<int,int>, char> > v[15];


bool moze(int i,int j)
{
    return (i>0 && i<=n && j>0 && j<=m);
}

bool check()
{ bool ret=true;
    For(i,1,n)
    {
      For(j,1,m)
    {
        good[i][j]=false;
       // printf("%c",b[i][j]);
    }
      //  printf("\n");
    }
   // printf("\n");

    For(i,1,n)
    For(j,1,m)
    {
        if (b[i][j]!='C' && b[i][j]!='.')
        good[i][j]=true;
        else
        if (b[i][j]=='C')
        {
            For(q,levi[i][j]+1,desni[i][j]-1)
            good[i][q]=true;
            For(q,gornji[i][j]+1,donji[i][j]-1)
            good[q][j]=true;
        }
    }
    For(i,1,n)
    For(j,1,m)
    if (good[i][j]==false) return false;
    return true;
}

bool help(int i,int j,int mask)
{
    int should=c[i][j]-'0',curr=0;
    if (moze(i-1,j) && (mask&(1<<(i-2)))) curr++;
    if (moze(i+1,j) && (mask&(1<<(i)))) curr++;
    if (moze(i,j-1) && b[i][j-1]=='C') curr++;
    if (curr>should) {return false;}
    if (should==curr) return true;
    if ((should==curr+1) && zab[i][j+1]!='z' && j!=m)
    {
        v[j].push_back({{i,j+1},zab[i][j+1]});
        zab[i][j+1]='m';
        return true;
    }
    return false;
}

bool resikol(char b[MAX][MAX],int col)
{  // cout<<col<<endl;

    if (col>m)
    {
        f++;
       // if (f>1000000) cout<<f<<" "<<endl;
        return (check());
    }
        For(i,0,((1<<n)-1))
        {
            //v.clear();
            ok=true; preg=0;r=0;
           /* For(j,1,n)
            {
                if (i&(1<<(j-1)))
                    printf("%c",'C');
                else printf(".");
            }*/
          //  printf("\n");
            For(j,1,n)
            {

                if (i&(1<<(j-1)))
                {
                    if ((zab[j][col]!='0') ||((preg!=0) && (donji[preg][col]==donji[j][col]))|| (b[j][col-1]=='C'))
                        {ok=false;// cout<<7<<endl;
                        break;}
                    preg=j;
                }

                else if (zab[j][col]=='m')
                {
                    //cout<<8<<endl;
                    ok=false;
                    break;
                }
                if (c[j][col]>='0' && c[j][col]<='4' && !help(j,col,i))
                {
                   // cout<<9<<endl;
                    ok=false; break;
                }
            }
            if (ok)
            {
                For(j,1,n)
                {
                    if (i&(1<<(j-1)))
                    {
                        b[j][col]='C';

                        {
                            v[col].push_back({{j,col+1},zab[j][col+1]});
                            zab[j][col+1]='g';
                          //  v[col].push_back({{j,col},zab[j][col]});
                          //  zab[j][col]='z';
                        }
                    }
                    else
                        if (zab[j][col]=='g')
                        {
                          if (zab[j][col+1]!='z')
                          {
                             v[col].push_back({{j,col+1},zab[j][col+1]});
                            zab[j][col+1]='g';
                           // v[col].push_back({{j,col},zab[j][col]});
                           // zab[j][col]='z';
                          }

                        }

                    if (resikol(b,col+1))
                        return true;

                    else
                    {
                       for(auto x:v[col])
                       zab[x.first.first][x.first.second]=x.second;
                       For(p,1,n)
                       if (b[p][col]=='C') b[p][col]='.';

                    }
                }
            }
        }
        return false;

}

int main()
{
    cin>>n>>m;
    For(i,1,n)
    {
        scanf("%s",s);
        For(j,1,m)
        {
            c[i][j]=s[j-1];
        if (c[i][j]=='.') r++;
        }

    }
    if (r==n*m)
    {
        For(i,1,n)
        {
            For(j,1,m)
                if (i==j)
                    printf("%c",'C');
                else
                    printf("%c",'.');
            printf("\n");
        }
        return 0;
    }
    For(i,1,n)
    For(j,1,m)
    {
        b[i][j]=c[i][j];
        if (c[i][j]=='.')
            zab[i][j]='0';
        else zab[i][j]='z',z++;
    }


    For(i,1,n)
        For(j,1,m)
        {

            if (c[i][j]!='.') levi[i][j]=j;
            else if (j==1) levi[i][j]=0;
            else levi[i][j]=levi[i][j-1];


            if (c[i][j]!='.') gornji[i][j]=i;
            else if (i==1) gornji[i][j]=0;
            else gornji[i][j]=gornji[i-1][j];
        }

    Ford(i,n,1)
        Ford(j,m,1)
        {

            if (c[i][j]!='.') desni[i][j]=j;
            else if (j==m) desni[i][j]=m+1;
            else desni[i][j]=desni[i][j+1];


            if (c[i][j]!='.') donji[i][j]=i;
            else if (i==n) donji[i][j]=n+1;
            else donji[i][j]=donji[i+1][j];
        }

/*
    For(i,1,n)
    {
        For(j,1,m)
        printf("%i",donji[i][j]);
        printf("\n");
    }*/



    if (resikol(b,1))
    {
        For(i,1,n)
        {
            For(j,1,m)
            printf("%c",b[i][j]);
            printf("\n");
        }
        return 0;
    }

     printf("-1");

    return 0;
}