#include <bits/stdc++.h>

using namespace std;

#define INFI 987654321
#define INFL 987654321987654321
#define MOD 1000000007

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T>
void read(T, int);

template<typename T>
void write(T, int);

template<typename T>
int sumFor(T, int, int);

template<typename T>
int sumFor(T, int);

int power(int, int, int);
int power(int, int);
void add(int&, int&);
int getRand();
int max(int, int, int);

/// //MAIN// ///

//int a[500005];
char mat[15][15];
//int dontDare[15][15];
vector<pair<int, int>> kocke;
int n, m;

int btopova(int x, int y){

    int bt = 0;
    if(x != n - 1 && mat[x+1][y] == 'C'){
        bt++;
    }
    if(x != 0 && mat[x-1][y] == 'C'){
        bt++;
    }
    if(y != m - 1 && mat[x][y+1] == 'C'){
        bt++;
    }
    if(y != 0 && mat[x][y-1] == 'C'){
        bt++;
    }

    return bt;
}

/*
void rek(int x, int y){

    if(x == n){
        bool wrks = true;
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < m; ++j){
                if(dontDare[i][j] <= 0 && mat[i][j] == '.'){
                    wrks = false;
                    break;
                }
            }
        }

        if(!wrks){
            return;
        }

        for(auto c : kocke){
            if(mat[c.first][c.second] - '0' != btopova(c.first, c.second)){
                wrks = false;
                break;
            }
        }

        if(!wrks){
            return;
        }

        for(int i = 0; i < n; ++i){
            for(int j = 0; j < m; ++j){
                cout << mat[i][j];
            }
            cout << "\n";
        }
        exit(0);
        return;
    }

    if(y == m - 1){
        rek(x + 1, 0);
    }else{
        rek(x, y + 1);
    }

    if(mat[x][y] != '.'){
        return;
    }

    if(dontDare[x][y] >= 1){
        return;
    }
    dontDare[x][y]++;
    mat[x][y] = 'C';

    for(int i = x + 1; i < n; ++i){
        if(mat[i][y] == '#' || (mat[i][y] >= '0' && mat[i][y] <= '4')){
            break;
        }
        dontDare[i][y]++;
    }
    for(int i = x - 1; i >= 0; --i){
        if(mat[i][y] == '#'  || (mat[i][y] >= '0' && mat[i][y] <= '4')){
            break;
        }
        dontDare[i][y]++;
    }
    for(int i = y + 1; i < m; ++i){
        if(mat[x][i] == '#' || (mat[x][i] >= '0' && mat[x][i] <= '4')){
            break;
        }
        dontDare[x][i]++;
    }
    for(int i = y - 1; i >= 0; --i){
        if(mat[x][i] == '#' || (mat[x][i] >= '0' && mat[x][i] <= '4')){
            break;
        }
        dontDare[x][i]++;
    }

    if(y == m - 1){
        rek(x + 1, 0);
    }else{
        rek(x, y + 1);
    }

    for(int i = x + 1; i < n; ++i){
        if(mat[i][y] == '#' || (mat[i][y] >= '0' && mat[i][y] <= '4')){
            break;
        }
        dontDare[i][y]--;
    }
    for(int i = x - 1; i >= 0; --i){
        if(mat[i][y] == '#'  || (mat[i][y] >= '0' && mat[i][y] <= '4')){
            break;
        }
        dontDare[i][y]--;
    }
    for(int i = y + 1; i < m; ++i){
        if(mat[x][i] == '#' || (mat[x][i] >= '0' && mat[x][i] <= '4')){
            break;
        }
        dontDare[x][i]--;
    }
    for(int i = y - 1; i >= 0; --i){
        if(mat[x][i] == '#' || (mat[x][i] >= '0' && mat[x][i] <= '4')){
            break;
        }
        dontDare[x][i]--;
    }
    mat[x][y] = '.';
}
*/
bool visited[15][15];

bool proveriCol(int x, int y){

    visited[x][y] = true;
    bool fnd = false;
    for(int i = x + 1; i < n; ++i){
        visited[i][y] = true;
        if(mat[i][y] == '#' || (mat[i][y] >= '0' && mat[i][y] <= '4')){
            break;
        }
        if(mat[i][y] == 'C'){
            fnd = true;
            break;
        }
    }
    if(fnd){
        return true;
    }
    for(int i = x - 1; i >= 0; --i){
        visited[i][y] = true;
        if(mat[i][y] == '#'  || (mat[i][y] >= '0' && mat[i][y] <= '4')){
            break;
        }
        if(mat[i][y] == 'C'){
            fnd = true;
            break;
        }
    }
    if(fnd){
        return true;
    }
    for(int i = y + 1; i < m; ++i){
        visited[x][i] = true;
        if(mat[x][i] == '#' || (mat[x][i] >= '0' && mat[x][i] <= '4')){
            break;
        }
        if(mat[x][i] == 'C'){
            fnd = true;
            break;
        }
    }
    if(fnd){
        return true;
    }
    for(int i = y - 1; i >= 0; --i){
        visited[x][i] = true;
        if(mat[x][i] == '#' || (mat[x][i] >= '0' && mat[x][i] <= '4')){
            break;
        }
        if(mat[x][i] == 'C'){
            fnd = true;
            break;
        }
    }
    if(fnd){
        return true;
    }
    return false;
}

void rek(int x, int y){

    if(x == n){

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

        bool wrks = true;
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < m; ++j){
                if(mat[i][j] == 'C'){
                    if(proveriCol(i, j)){
                        wrks = false;
                        break;
                    }
                }
            }
        }
        if(!wrks){
            return;
        }

        for(auto c : kocke){
            if(mat[c.first][c.second] - '0' != btopova(c.first, c.second)){
                wrks = false;
                break;
            }
        }
        if(!wrks){
            return;
        }

        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                if((mat[i][j] == '.' || mat[i][j] == 'C') && !visited[i][j]){
                    wrks = false;
                    break;
                }
            }
        }

        if(!wrks){
            return;
        }

        for(int i = 0; i < n; ++i){
            for(int j = 0; j < m; ++j){
                cout << mat[i][j];
            }
            cout << "\n";
        }
        exit(0);
        return;
    }

    if(y == m - 1){
        rek(x + 1, 0);
    }else{
        rek(x, y + 1);
    }

    if(mat[x][y] != '.'){
        return;
    }

    mat[x][y] = 'C';

    if(y == m - 1){
        rek(x + 1, 0);
    }else{
        rek(x, y + 1);
    }

    mat[x][y] = '.';
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            cin >> mat[i][j];
            if(mat[i][j] >= '0' && mat[i][j] <= '4'){
                kocke.push_back({i, j});
            }
        }
    }

    rek(0, 0);
    cout << "-1\n";
    return 0;
}

/// /////////////////////////////////////////////

int max(int m_a, int m_b, int m_c){
    if(m_c >= m_a && m_c >= m_b){
        return m_c;
    }
    return m_a >= m_b ? m_a : m_b;
}

int getRand(){
    return rng();
}

void add(int& m_a, int& m_b){
    m_a = (m_a + m_b) % MOD;
}

template<typename T>
void write(T m_pnter, int m_size){
    for(int i = 0; i < m_size; ++i){
        cout << m_pnter[i] << " ";
    }
    cout << "\n";
}

template<typename T>
void read(T m_pnter, int m_size){
    for(int i = 0; i < m_size; ++i){
        cin >> m_pnter[i];
    }
}

template<typename T>
int sumFor(T m_pnter, int m_l, int m_r){
    int m_sum = 0;
    for(int i = m_l; i < m_r; ++i){
        m_sum += m_pnter[i];
    }
    return m_sum;
}

template<typename T>
int sumFor(T m_pnter, int m_r){
    int m_sum = 0;
    for(int i = 0; i < m_r; ++i){
        m_sum += m_pnter[i];
    }
    return m_sum;
}

int power(int m_a, int m_b, int m_mod){
    int m_res = 1;
    while(m_b > 0){
        if(m_b % 2 == 1){
            m_res = (m_res * m_a) % m_mod;
        }
        m_b /= 2;
        m_a = (m_a * m_a) % m_mod;
    }
    return m_res;
}

int power(int m_a, int m_b){
    int m_res = 1;
    while(m_b > 0){
        if(m_b % 2 == 1){
            m_res = m_res * m_a;
        }
        m_b /= 2;
        m_a = m_a * m_a;
    }
    return m_res;
}