#include <bits/stdc++.h>

using namespace std;

int n, m;
vector<pair<int, int>> tacke;

bool rekurzija(int uv, int i, int j, char a[][20])
{
    if(i == n && j == 0)
    {
        int pom[n][m];
        for(int i = 0; i < n; i++)
            for(int j = 0; j < m; j++)
            {
                if(a[i][j] == '.')
                    pom[i][j] = 0;
                else
                    pom[i][j] = 1;
            }

        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
            {
                if(isdigit(a[i][j]))
                {
                    int nmofC = 0;
                    if(j != 0 && a[i][j-1] == 'C')
                        nmofC++;
                    if(i != n-1 && a[i+1][j] == 'C')
                        nmofC++;
                    if(j != m-1 && a[i][j+1] == 'C')
                        nmofC++;
                    if(i != 0 && a[i-1][j] == 'C')
                        nmofC++;

                    if(nmofC != a[i][j]-'0')
                        return false;
                }

                if(a[i][j] == 'C')
                {
                    for(int ii = i+1; ii < n; ii++)
                    {
                        if(a[ii][j] == 'C')
                            return false;
                        if(a[ii][j] != '.')
                            break;
                        pom[ii][j] = 1;
                    }

                    for(int ii = i-1; ii >= 0; ii--)
                    {
                        if(a[ii][j] == 'C')
                            return false;
                        if(a[ii][j] != '.')
                            break;
                        pom[ii][j] = 1;
                    }

                    for(int jj = j+1; jj < m; jj++)
                    {
                        if(a[i][jj] == 'C')
                            return false;
                        if(a[i][jj] != '.')
                            break;
                        pom[i][jj] = 1;
                    }

                    for(int jj = j-1; jj >= 0; jj--)
                    {
                        if(a[i][jj] == 'C')
                            return false;
                        if(a[i][jj] != '.')
                            break;
                        pom[i][jj] = 1;
                    }
                }
            }
        }

        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < m; j++)
                if(!pom[i][j])
                    return false;
        }

        //cout << "svaka cast ako si ovde dosao\n";
        return true;
    }

    if(rekurzija(uv+1, tacke[uv+1].first, tacke[uv+1].second, a))
        return true;
    a[i][j] = 'C';
    if(rekurzija(uv+1, tacke[uv+1].first, tacke[uv+1].second, a))
        return true;
    a[i][j] = '.';

    return false;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    set<char> s;
    char a[n][20];
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            cin >> a[i][j];
            s.insert(a[i][j]);
            if(a[i][j] == '.')
            tacke.push_back({i, j});
        }
    }
    tacke.push_back({n, 0});

    if(s.size() == 1)
    {
        if(*s.begin() == '.')
        {
            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < m; j++)
                {
                    if(i == j)
                        cout << "C";
                    else
                        cout << ".";
                }
                cout << "\n";
            }
        }

        else if(*s.begin() == '#' || *s.begin() == '0')
        {
            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < m; j++)
                {
                    cout << a[i][j];
                }
                cout << "\n";
            }
        }
    }

    else if(tacke.size() <= 23)
    {
        if(rekurzija(0, tacke[0].first, tacke[0].second, a))
        {
            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < m; j++)
                {
                    cout << a[i][j];
                }
                cout << "\n";
            }
        }

        else
            cout << -1;
    }

    else
        cout << -1;
}
/*
4 7
#......
.......
.......
.......

*/