#include <bits/stdc++.h>

using namespace std;

long long n, m, brojTacaka=0;
char tabla[15][15];
bool bio [15][15];
vector <pair<int, int>> topovi;

void ispisi()
{
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            cout<<tabla[i][j];
        }
        cout<<endl;
    }
    exit(0);
}

bool tablaJeOkej()
{
    int brojMogucih=0;
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            if (tabla[i][j]>='1' && tabla[i][j]<='4')
            {
                //DOVRSI!!!
                //IZRACUNAS BROJ KOJI GA OKRUZUJE I PROVERIS DA LI JE TO TAJ BROJ K
                int kolikoGaOkruzuje=0;
                if (i>0 && j>0)
                {
                    if (i<n-1 && j<m-1)
                    {
                        if (tabla[i-1][j]=='C')
                            kolikoGaOkruzuje++;
                        if (tabla[i][j-1]=='C')
                            kolikoGaOkruzuje++;
                        if (tabla[i][j+1]=='C')
                            kolikoGaOkruzuje++;
                        if (tabla[i+1][j]=='C')
                            kolikoGaOkruzuje++;
                    }
                    else if (i<n-1)
                    {
                        if (tabla[i-1][j]=='C')
                            kolikoGaOkruzuje++;
                        if (tabla[i][j-1]=='C')
                            kolikoGaOkruzuje++;
                        if (tabla[i+1][j]=='C')
                            kolikoGaOkruzuje++;
                    }
                    else if (j<n-1)
                    {
                        if (tabla[i-1][j]=='C')
                            kolikoGaOkruzuje++;
                        if (tabla[i][j-1]=='C')
                            kolikoGaOkruzuje++;
                        if (tabla[i][j+1]=='C')
                            kolikoGaOkruzuje++;
                    }
                    else
                    {
                        if (tabla[i-1][j]=='C')
                            kolikoGaOkruzuje++;
                        if (tabla[i][j-1]=='C')
                            kolikoGaOkruzuje++;
                    }
                }
                else
                {
                    if (i>0)
                    {
                        if (i<n-1)
                        {
                            if (tabla[i-1][j]=='C')
                                kolikoGaOkruzuje++;
                            if (tabla[i][j+1]=='C')
                                kolikoGaOkruzuje++;
                            if (tabla[i+1][j]=='C')
                                kolikoGaOkruzuje++;
                        }
                        else
                        {
                            if (tabla[i-1][j]=='C')
                                kolikoGaOkruzuje++;
                            if (tabla[i][j+1]=='C')
                                kolikoGaOkruzuje++;
                        }
                    }
                    else if (j>0)
                    {
                        if (j<n-1)
                        {
                            if (tabla[i][j-1]=='C')
                                kolikoGaOkruzuje++;
                            if (tabla[i][j+1]=='C')
                                kolikoGaOkruzuje++;
                            if (tabla[i+1][j]=='C')
                                kolikoGaOkruzuje++;
                        }
                        else
                        {
                            if (tabla[i][j-1]=='C')
                                kolikoGaOkruzuje++;
                            if (tabla[i+1][j]=='C')
                                kolikoGaOkruzuje++;
                        }
                    }
                    else
                    {
                        if (tabla[i][j+1]=='C')
                            kolikoGaOkruzuje++;
                        if (tabla[i+1][j]=='C')
                            kolikoGaOkruzuje++;
                    }
                }

                if (tabla[i][j]-'0'!=kolikoGaOkruzuje)
                {
                    cout<<"kockica"<<endl;
                    return false;
                }
            }
            if (tabla[i][j]=='C')
            {
                pair<int, int> par;
                par.first=i; par.second=j;
                topovi.push_back(par);
                //PROVERI DA LI NAPADA NEKOGA
                for (int g=j-1; g>=0; g--)
                {
                    if (tabla[i][g]=='C')
                    {
                        cout<<"jbg"<<endl;
                        return false;
                    }
                    if (tabla[i][g]=='#' || (tabla[i][g]>='1' && tabla[i][g]<='4'))
                        break;
                }
                for (int g=j+1; g<m; g++)
                {
                    if (tabla[i][g]=='C')
                    {
                        cout<<"jbg"<<endl;
                        return false;
                    }
                    if (tabla[i][g]=='#' || (tabla[i][g]>='1' && tabla[i][g]<='4'))
                        break;
                }
                for (int g=i-1; g>=0; g--)
                {
                    if (tabla[g][j]=='C')
                    {
                        cout<<"jbg"<<endl;
                        return false;
                    }
                    if (tabla[g][j]=='#' || (tabla[g][j]>='1' && tabla[g][j]<='4'))
                        break;
                }
                for (int g=i+1; g>=0; g--)
                {
                    if (tabla[g][j]=='C')
                    {
                        cout<<"jbg"<<endl;
                        return false;
                    }
                    if (tabla[g][j]=='#' || (tabla[g][j]>='1' && tabla[g][j]<='4'))
                        break;
                }
            }

            for (int m=0; m<topovi.size(); m++)
            {
                brojMogucih++;
                int a=topovi[m].first;
                int b=topovi[m].second;
                for (int g=b-1; g>=0; g--)
                {
                    if (tabla[a][g]=='.' && bio[a][g]==false)
                    {
                        brojMogucih++;
                        bio[a][g]==false;
                    }
                    if (tabla[a][g]=='#' || (tabla[a][g]>='1' && tabla[a][g]<='4'))
                        break;
                }
                for (int g=b+1; g<m; g++)
                {
                    if (tabla[a][g]=='C' && bio[a][g]==false)
                    {
                        brojMogucih++;
                        bio[a][g]==false;
                    }
                    if (tabla[a][g]=='#' || (tabla[a][g]>='1' && tabla[a][g]<='4'))
                        break;
                }
                for (int g=a-1; g>=0; g--)
                {
                    if (tabla[g][b]=='C' && bio[g][b]==false)
                    {
                        brojMogucih++;
                        bio[g][b]==false;
                    }
                    if (tabla[g][b]=='#' || (tabla[g][b]>='1' && tabla[g][b]<='4'))
                        break;
                }
                for (int g=a+1; g>=0; g--)
                {
                    if (tabla[g][b]=='C' && bio[g][b]==false)
                    {
                        brojMogucih++;
                        bio[g][b]==false;
                    }
                    if (tabla[g][b]=='#' || (tabla[g][b]>='1' && tabla[g][b]<='4'))
                        break;
                }
            }

        }
    }

    if (brojMogucih<brojTacaka)
    {
        cout<<"NE GADJAJU SVE PRAZNE"<<endl;
        return false;
    }
    return true;
}

void uradi(int i, int j)
{
    if (i==n-1 && j==m-1)
    {
        if (tablaJeOkej())
            ispisi();
        return;
    }
    if (tabla[i][j]=='.')
    {
        tabla[i][j]='.';
        if (j==m-1)
            uradi(i+1, 0);
        else
            uradi(i, j+1);

        tabla[i][j]='C';
        if (j==m-1)
            uradi(i+1, 0);
        else
            uradi(i, j+1);
    }
    else
    {
        if (j==m-1)
            uradi(i+1, 0);
        else
            uradi(i, j+1);
    }
}

int main()
{
    cin>>n>>m;
    bool t=false;

    for (int i=0; i<15; i++)
    {
        for (int j=0; j<15; j++)
            bio[i][j]=false;
    }

    for (int i=0; i<n; i++)
    {
        for (int j=0; j<m; j++)
        {
            cin>>tabla[i][j];
            if (tabla[i][j]!='.')
                t=true;
            else
                brojTacaka++;
        }
    }

    if (t==false)
    {
        if(n>=m)
        {
            for (int i=0; i<n; i++)
            {
                for (int j=0; j<m; j++)
                {
                    if (i==j)
                        cout<<"C";
                    else
                        cout<<".";
                }
                cout<<endl;
            }
        }
        else
        {
            for (int i=0; i<n; i++)
            {
                for (int j=0; j<m; j++)
                {
                    if (n-i-1==j)
                        cout<<"C";
                    else
                        cout<<".";
                }
                cout<<endl;
            }
        }
        exit(0);
    }


    else
    {
        uradi(0, 0);
    }

    cout<<-1;

}