#include <bits/stdc++.h>
using namespace std;

struct mesto
{
    int x1;
    int y1;
};

bool t=false;

int brojTopovaUOkolini(vector<vector<char> > v,int x,int y,int n,int m)
{
    int br=0;
    if(x>0 && v[x-1][y]=='C')
        br++;
    if(x<n-1 && v[x+1][y]=='C')
        br++;
    if(y>0 && v[x][y-1]=='C')
        br++;
    if(y<m-1 && v[x][y+1]=='C')
        br++;
    return br;
}

void f(vector<vector<char> > v,int n,int m,vector<mesto> top,int i1,int j1)
{
    if(t)
        return;
    bool provera=true;
    if(i1==n && j1==m-1)
    {
        for (int i=0;i<top.size() && provera;i++)
            for (int j=i+1;j<top.size() && provera;j++)
                if(top[i].x1 == top[j].x1)
                {
                    bool napad=true;
                    for (int g=min(top[i].y1,top[j].y1)+1;g<=max(top[i].y1,top[j].y1)-1;g++)
                        if(v[top[i].x1][g]!='.')
                            napad=false;
                    if(napad)
                        provera=false;
                }
                else if(top[i].y1 == top[j].y1)
                {
                    bool napad=true;
                    for (int g=min(top[i].x1,top[j].x1)+1;g<=max(top[i].x1,top[j].x1)-1;g++)
                        if(v[g][top[i].y1]!='.')
                            napad=false;
                    if(napad)
                        provera=false;
                }
        if(provera==false)
            return;
        vector<vector<char> > pokriveno(n,vector<char> (m,'0'));
        for (int i=0;i<n;i++)
            for (int j=0;j<m;j++)
                if(v[i][j]=='.')
                    pokriveno[i][j]='0';
                else pokriveno[i][j]='1';

        for (int i=0;i<n && provera;i++)
            for (int j=0;j<m && provera;j++)
            {
                if(v[i][j]=='C')
                {
                    if(i>0)
                    for (int x=i-1;x>=0;x--)
                    {
                        if(v[x][j]=='.')
                            pokriveno[x][j]='1';
                        else
                            break;
                    }
                    if(j>0)
                    for (int y=j-1;y>=0;y--)
                    {
                        if(v[i][y]=='.')
                            pokriveno[i][y]='1';
                        else
                            break;
                    }
                    if(i<n-1)
                    for (int x=i+1;x<n;x++)
                    {
                        if(v[x][j]=='.')
                            pokriveno[x][j]='1';
                        else
                            break;
                    }
                    if(j<m-1)
                    for (int y=j+1;y<m;y++)
                    {
                        if(v[i][y]=='.')
                            pokriveno[i][y]='1';
                        else
                            break;
                    }
                }
                else if(v[i][j]=='0' && brojTopovaUOkolini(v,i,j,n,m)!=0)
                    provera=false;
                else if(v[i][j]=='1' && brojTopovaUOkolini(v,i,j,n,m)!=1)
                    provera=false;
                else if(v[i][j]=='2' && brojTopovaUOkolini(v,i,j,n,m)!=2)
                    provera=false;
                else if(v[i][j]=='3' && brojTopovaUOkolini(v,i,j,n,m)!=3)
                    provera=false;
                else if(v[i][j]=='4' && brojTopovaUOkolini(v,i,j,n,m)!=4)
                    provera=false;
            }
        for (int i=0;i<n && provera;i++)
            for (int j=0;j<m && provera;j++)
                if(pokriveno[i][j]=='0')
                    provera=false;
        if(provera==false)
            return;


        t=true;
        for (int i=0;i<n;i++)
        {
            for (int j=0;j<m;j++)
                cout << v[i][j];
            cout << endl;
        }
        return;
    }
    else if(t==false)
    {
    if(i1==n && j1<m-1)
    {
        i1=0;
        j1++;
    }
    f(v,n,m,top,i1+1,j1);
    if(v[i1][j1]=='.')
    {
        top.push_back({i1,j1});
        v[i1][j1]='C';
        for (int i=0;i<top.size() && provera;i++)
            for (int j=i+1;j<top.size() && provera;j++)
                if(top[i].x1 == top[j].x1)
                {
                    bool napad=true;
                    for (int g=min(top[i].y1,top[j].y1)+1;g<=max(top[i].y1,top[j].y1)-1;g++)
                        if(v[top[i].x1][g]!='.')
                            napad=false;
                    if(napad)
                        provera=false;
                }
                else if(top[i].y1 == top[j].y1)
                {
                    bool napad=true;
                    for (int g=min(top[i].x1,top[j].x1)+1;g<=max(top[i].x1,top[j].x1)-1;g++)
                        if(v[g][top[i].y1]!='.')
                            napad=false;
                    if(napad)
                        provera=false;
                }
        if(provera)
            f(v,n,m,top,i1+1,j1);
    }
    }
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,m;
    cin >> n >> m;
    bool sveZvezdice=true;
    vector<vector<char> > v(n,vector<char> (m,'0'));
    for (int i=0;i<n;i++)
        for (int j=0;j<m;j++)
            cin >> v[i][j];
    for (int i=0;i<n && sveZvezdice;i++)
        for (int j=0;j<m && sveZvezdice;j++)
            if(v[i][j]!='.')
            {
                sveZvezdice=false;
                break;
            }
    if(sveZvezdice)
    {
        for (int i=0;i<n;i++,cout << endl)
            for (int j=0;j<m;j++)
                if(i==j)
                    cout << 'C';
                else cout << '.';
    }
    else
    {
        vector<mesto> top;
        f(v,n,m,top,0,0);
        if(t==false)
            cout << -1;
    }
}