#include <bits/stdc++.h>

using namespace std;

int n;
int m;
int mat[15][15];
int mat1[15][15];
string s;
vector<pair<int,int>> okoovih;
vector<pair<int,int>> polja;
vector<pair<int,int>> slobodnaPolja;
int napadnuto[15][15];
bool ubaceno[15][15];

bool mozeDaSePostavi(int red,int kol)
{
    if(napadnuto[red][kol]==0 && mat[red][kol]==-1) return true;
    return false;
}

bool slobodnoPored(int red,int kol)
{
    int nr;
    int nk;
    
    nr=red+1;
    nk=kol;
    
    if(nr>=1 && nr<=n && nk>=1 && nk<=m)
    {
        if(mat[nr][nk]==0) return false;
    }
    
    nr=red-1;
    nk=kol;
    
    if(nr>=1 && nr<=n && nk>=1 && nk<=m)
    {
        if(mat[nr][nk]==0) return false;
    }
    
    nr=red;
    nk=kol+1;
    
    if(nr>=1 && nr<=n && nk>=1 && nk<=m)
    {
        if(mat[nr][nk]==0) return false;
    }
    
    nr=red;
    nk=kol-1;
    
    if(nr>=1 && nr<=n && nk>=1 && nk<=m)
    {
        if(mat[nr][nk]==0) return false;
    }
    
    return true;
}

void napadni(int red,int kol)
{
    for(int i=kol+1;i<=m && mat[red][i]==-1;i++) napadnuto[red][i]++;
    for(int i=kol-1;i>=1 && mat[red][i]==-1;i--) napadnuto[red][i]++;
    for(int i=red+1;i<=n && mat[i][kol]==-1;i++) napadnuto[i][kol]++;
    for(int i=red-1;i>=1 && mat[i][kol]==-1;i--) napadnuto[i][kol]++;
}

void oslobodi(int red,int kol)
{
    for(int i=kol+1;i<=m && mat[red][i]==-1;i++) napadnuto[red][i]--;
    for(int i=kol-1;i>=1 && mat[red][i]==-1;i--) napadnuto[red][i]--;
    for(int i=red+1;i<=n && mat[i][kol]==-1;i++) napadnuto[i][kol]--;
    for(int i=red-1;i>=1 && mat[i][kol]==-1;i--) napadnuto[i][kol]--;
}

void smanji(int red,int kol)
{
    if(mat[red+1][kol]>0) mat[red+1][kol]--;
    if(mat[red-1][kol]>0) mat[red-1][kol]--;
    if(mat[red][kol+1]>0) mat[red][kol+1]--;
    if(mat[red][kol-1]>0) mat[red][kol-1]--;
}

void povecaj(int red,int kol)
{
    if(mat[red+1][kol]>=0) mat[red+1][kol]++;
    if(mat[red-1][kol]>=0) mat[red-1][kol]++;
    if(mat[red][kol+1]>=0) mat[red][kol+1]++;
    if(mat[red][kol-1]>=0) mat[red][kol-1]++;
}

bool validanRaspored()
{
    for(pair<int,int> p : okoovih)
    {
        int r=p.first;
        int k=p.second;
        if(mat[r][k]>0) return false;
    }
    
    return true;
}

void formatirajRaspored()
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(mat1[i][j]==-2)
            {
                cout << "#";
            }
            else if(mat1[i][j]==-1)
            {
                if(mat[i][j]==5)
                {
                    cout << "C";
                }
                else
                {
                    cout << ".";
                }
            }
            else cout << mat1[i][j];
        }
        cout << "\n";
    }
    
    exit(0);
}

void uzmiOstaleSlobodne()
{
   slobodnaPolja.clear();
   for(int i=1;i<=n;i++)
   {
       for(int j=1;j<=m;j++)
       {
           if(mat[i][j]==-1 && napadnuto[i][j]==0)
           {
               slobodnaPolja.push_back({i,j});
           }
       }
   }
}

bool sadaValidan()
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(mat1[i][j]==-1)
            {
                if(napadnuto[i][j]==0) return false;
            }
        }
    }
    
    return true;
}

void postaviOstaleSlobodne(int indeks)
{
    if(indeks==slobodnaPolja.size())
    {
        if(sadaValidan())
        {
            formatirajRaspored();
        }
    }
    else
    {
       int red=slobodnaPolja[indeks].first;
       int kol=slobodnaPolja[indeks].second;
       
       if(mozeDaSePostavi(red,kol) && slobodnoPored(red,kol))
        {
                mat[red][kol]=5;
                napadnuto[red][kol]++;
                napadni(red,kol);
                smanji(red,kol);
                postaviOstaleSlobodne(indeks+1);
                
                mat[red][kol]=-1;
                napadnuto[red][kol]--;
                oslobodi(red,kol);
                povecaj(red,kol);
                postaviOstaleSlobodne(indeks+1);
        }
        else
        {
            postaviOstaleSlobodne(indeks+1);
        }
    }
}

void postavi(int indeks)
{
    if(indeks==polja.size())
    {
        if(validanRaspored())
        {
           uzmiOstaleSlobodne();
           postaviOstaleSlobodne(0);
        }
    }
    else
    {
        int red=polja[indeks].first;
        int kol=polja[indeks].second;
               
        if(mozeDaSePostavi(red,kol) && slobodnoPored(red,kol))
        {
                mat[red][kol]=5;
                napadnuto[red][kol]++;
                napadni(red,kol);
                smanji(red,kol);
                postavi(indeks+1);
                
                mat[red][kol]=-1;
                napadnuto[red][kol]--;
                oslobodi(red,kol);
                povecaj(red,kol);
                postavi(indeks+1);
        }
        else
        {
            postavi(indeks+1);
        }
    }
}

void ubaci(int r,int k)
{
    int tr;
    int tk;
    
    tr=r+1;
    tk=k;
    
    if(tr>=1 && tr<=n && tk>=1 && tk<=m && mat1[tr][tk]==-1 && !ubaceno[tr][tk]) 
    {
        polja.push_back({tr,tk});
        ubaceno[tr][tk]=true;
    }
    
    tr=r-1;
    tk=k;
    
    if(tr>=1 && tr<=n && tk>=1 && tk<=m && mat1[tr][tk]==-1 && !ubaceno[tr][tk]) 
    {
        polja.push_back({tr,tk});
        ubaceno[tr][tk]=true;
    }
    
    tr=r;
    tk=k-1;
    
    if(tr>=1 && tr<=n && tk>=1 && tk<=m && mat1[tr][tk]==-1 && !ubaceno[tr][tk]) 
    {
        polja.push_back({tr,tk});
        ubaceno[tr][tk]=true;
    }
    
    tr=r;
    tk=k+1;
    
    if(tr>=1 && tr<=n && tk>=1 && tk<=m && mat1[tr][tk]==-1 && !ubaceno[tr][tk]) 
    {
        polja.push_back({tr,tk});
        ubaceno[tr][tk]=true;
    }
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
    
    cin >> n >> m;
    
    for(int i=1;i<=n;i++)
    {
        cin >> s;
        
        for(int j=0;j<m;j++)
        {
            if(s[j]=='.')
            {
                mat1[i][j+1]=-1;
            }
            else if(s[j]=='#')
            {
                mat1[i][j+1]=-2;
            }
            else
            {
                mat1[i][j+1]=s[j]-'0';
                if(mat1[i][j+1]>0) okoovih.push_back({i,j+1});
            }
            
            mat[i][j+1]=mat1[i][j+1];
            napadnuto[i][j+1]=0;
            ubaceno[i][j+1]=false;
        }
    }
    
    for(pair<int,int> p : okoovih)
    {
        int red=p.first;
        int kol=p.second;
        
        ubaci(red,kol);
    }
    
    postavi(0);
    
    cout << "-1";
    
    return 0;
}