#include <bits/stdc++.h>

using namespace std;

int main()
{
    int N, M;
    cin >>N>>M;
    bool bilosta = true;
    char matrica [N][M];
    for (int i=0;i<N;i++)
    {
        for (int j=0;j<M;j++)
        {
            cin >>matrica[i][j];
            if (matrica[i][j]!= '.')
                bilosta = false;
        }
    }
    if (bilosta)
        for (int i=0;i<N;i++)
        {
        for (int j=0;j<M;j++)
        cout << matrica[i][j];
        cout<<endl;
        }

    if (M==1)
    {
        bool mozeli= true;
        if (matrica [0][0]=='2' || matrica [N][0]=='2')
            {
                cout <<-1;
                return 0;
            }
            if (matrica [0][0]=='3' || matrica [N][0]=='3')
            {
                cout <<-1;
                return 0;
            }
            if (matrica [0][0]=='4' || matrica [N][0]=='4')
            {
                cout <<-1;
                return 0;
            }
        for (int i=0;i<N;i++)
        {
            if (matrica [i][1] == 3 || matrica [i][1] == 4)
            {
                cout <<-1;
                return 0;
            }
            if (matrica [i][1]== '1')
            {
                if (matrica [i-1][1]=='.' && mozeli)
                {
                    matrica [i-1][1]= 'C';
                }
                    else if (matrica [i+1][1]=='.')
                    {
                     matrica [i+1][1] = 'C';
                     mozeli = false;
                    }
                        else {
                            cout <<-1;
                            return 0;}
            }
            if (matrica [i][1]== '2')
            {
                if (matrica [i-1][1] != '.' || matrica [i+1][1] !='.')
                {
                    cout <<-1;
                    return 0;
                }
                matrica [i-1][1] = 'C';
                matrica [i+1][1] = 'C';
            }
             if (matrica [i][1]== '#') mozeli = true;
            }
        }
    if (M == 2)
        {
          if (matrica [0][0]== '3' || matrica [N][0]=='3')
            {
                cout <<-1;
                return 0;
            }
          if (matrica [0][1]=='3' || matrica [N][1]=='3')
            {
                cout <<-1;
                return 0;
            }
            if (matrica [0][0]== '4' || matrica [N][0]=='4')
            {
                cout <<-1;
                return 0;
            }
          if (matrica [0][1]=='4' || matrica [N][1]=='4')
            {
                cout <<-1;
                return 0;
            }
             bool mozeli1 = true;
        for (int i=0;i<N;i++)
        {
            if (matrica [i][1] == '4')
            {
                cout <<-1;
                return 0;
            }
            if (matrica [i][1]== '1')
            {
                if (matrica [i-1][1]=='.' && mozeli1)
                {
                    matrica [i-1][1]= 'C';
                }
                    else if (matrica [i+1][1]=='.')
                    {
                     matrica [i+1][1] = 'C';
                     mozeli1 = false;
                    }
                        else if (matrica[i][2]=='.')
                        {
                            matrica [i][2] == 'C';
                        }
                        else {
                            cout <<-1;
                            return 0;
                        }
            }
            if (matrica [i][1] == '3')
            {
                 if (matrica [i-1][1] != '.' || matrica [i+1][1] !='.' || matrica [i][2] != '.')
                {
                    cout <<-1;
                    return 0;
                }
                matrica [i-1][1] = 'C';
                matrica [i+1][1] = 'C';
                matrica [i][2] = 'C';
            }

             if (matrica [i][1]== '#') mozeli1 = true;
            }
            for (int i=0;i<N;i++)
        {
            if (matrica [i][2] == '4')
            {
                cout <<-1;
                return 0;
            }
            if (matrica [i][2]== '1')
            {
                if (matrica [i-1][2]=='.' && mozeli1)
                {
                    matrica [i-1][2]= 'C';
                }
                    else if (matrica [i+1][2]=='.')
                    {
                     matrica [i+1][2] = 'C';
                     mozeli1 = false;
                    }
                        else if (matrica[i][1]=='.')
                        {
                            matrica [i][1] == 'C';
                        }
                        else {
                            cout <<-1;
                            return 0;
                        }
            }
            if (matrica [i][2] == '3')
            {
                 if (matrica [i-1][2] != '.' || matrica [i+1][1] !='.' || matrica [i][1] != '.')
                {
                    cout <<-1;
                    return 0;
                }
                matrica [i-1][2] = 'C';
                matrica [i+1][2] = 'C';
                matrica [i][1] = 'C';
            }

             if (matrica [i][2]== '#') mozeli1 = true;
            }

        }

        for (int i=0;i<N;i++)
        {
        for (int j=0;j<M;j++)
        cout << matrica[i][j];
        cout<<endl;
        }
    return 0;

}