#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);
}
int main(){
    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;
            }
        }
    }
    for(long i = 1; i <= n; i++){
        for(long j = 1; j <= m; j++){
            if(mat[i][j] >= '0' && mat[i][j] <= '4'){
                if(ima(i,j) < mat[i][j]-'0'){
                    ne();
                }
            }
        }
    }
    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;
    }
    if(n <= 2 && m <= 2){
        if(n == 1 && m == 1){
            if(mat[1][1] == '.'){
                cout << "C" << endl;
                return 0;
            }
            else{
                cout << mat[1][1] << endl;
                return 0;
            }
        }
        
    }
}