#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <ll,ll> p;
const ll N = 12;
ll n,m;
char mat[N][N];
vector <p> v;
bool ok(ll i,ll j){
    return (1 <= i && i <= n && 1 <= j && j <= m);
}
ll ima(ll i,ll j){
    ll br = 0;
    for(auto f : v){
        ll i1 = i + f.first,j1 = j + f.second;
        if(ok(i1,j1) && mat[i1][j1] == '.'){
            br++;
        }
    }
    return br;
}
void ne(){
    cout << "-1" << endl;
    exit(0);
}
vector <p> tacke;
ll cnt = 0;
ll kolko = 0,pocx,pocy;
bool visited[N][N];
void levo(ll x,ll y){
    visited[x][y] = 1;
    if(ok(x,y-1)){
        if(mat[x][y-1] == 'C'){
            kolko = 1;
            return;
        }
        if(mat[x][y-1] != '.'){
            return;
        }
        levo(x,y-1);
    }
}
void desno(ll x,ll y){
    visited[x][y] = 1;
    if(ok(x,y+1)){
        if(mat[x][y+1] == 'C'){
            kolko = 1;
            return;
        }
        if(mat[x][y+1] != '.'){
            return;
        }
        desno(x,y+1);
    }
}
void gore(ll x,ll y){
    visited[x][y] = 1;
    if(ok(x+1,y)){
        if(mat[x+1][y] == 'C'){
            kolko = 1;
            return;
        }
        if(mat[x+1][y] != '.'){
            return;
        }
        gore(x+1,y);
    }
}
void dole(ll x,ll y){
    visited[x][y] = 1;
    if(ok(x-1,y)){
        if(mat[x-1][y] == 'C'){
            kolko = 1;
            return;
        }
        if(mat[x-1][y] != '.'){
            return;
        }
        dole(x-1,y);
    }
}
bool check(ll nesto){
    memset(visited,false,sizeof(visited));
    for(long i = 1; i <= n; i++){
        for(long j = 1; j <= m; j++){
            if(mat[i][j] == 'C'){
                kolko = 0;
                pocx = i,pocy = j;
                gore(i,j);
                if(kolko){
                    return false;
                }
                dole(i,j);
                if(kolko){
                    return false;
                }
                levo(i,j);
                if(kolko){
                    return false;
                }
                desno(i,j);
                if(kolko){
                    return false;
                }
            }
            if(mat[i][j] >= '0' && mat[i][j] <= '4'){
                ll k = (mat[i-1][j] == 'C') + (mat[i+1][j] == 'C') + (mat[i][j-1] == 'C') + (mat[i][j+1] == 'C');
                if(k != mat[i][j] - '0'){
                    return false;
                }
            }
        }
    }
    for(long i = 1; i <= n; i++){
        for(long j = 1; j <= m; j++){
            if(mat[i][j] == '.' && !visited[i][j]){
                return false;
            }
        }
    }
    return true;
}
int main(){
    ios_base::sync_with_stdio(false);
    v.push_back(p(0,1));
    v.push_back(p(1,0));
    v.push_back(p(-1,0));
    v.push_back(p(0,-1));
    cin >> n >> m;
    bool prvi = true;
    for(long i = 1; i <= n; i++){
        string s;
        cin >> s;
        for(long j = 1; j <= m; j++){
            mat[i][j] = char(s[j-1]);
            if(mat[i][j] != '.'){
                prvi = 0;
            }
            else{
                cnt++;
                tacke.push_back(p(i,j));
            }
        }
    }
    //ll st = clock();
    if(prvi){
        for(long i = 1; i <= min(n,m); i++){
            mat[i][i] = 'C';
        }
        for(long i = 1; i <= n; i++){
            for(long j = 1; j <= m; j++){
                cout << mat[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    ll gr = 1;
    for(long i = 0; i < cnt; i++){
        gr *= 2;
    }
    for(ll mask = 0; mask < gr; mask++){
        ll t = 0;
        for(long j = 0; j < cnt; j++){
            if(mask & (1 << j)){
                mat[tacke[j].first][tacke[j].second] = 'C';
                t++;
            }
            else{
                mat[tacke[j].first][tacke[j].second] = '.';
            }
        }
        if(check(t)){
            for(long i = 1; i <= n; i++){
                for(long j = 1; j <= m; j++){
                    cout << mat[i][j];
                }
                cout << endl;
            }
            //cout << clock()-st << endl;
            return 0;
        }
    }
    //cout << clock()-st << endl;
    ne();
}