#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define mid(l, r) ((l)+(r))/2
#define len(a) (a).length()
#define sz(a) (a).size()
#define xx first
#define yy second
#define inf int(2e9)
#define ff(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i, a, b) for(int (i) = (a); (i) >= (b); --(i))


using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

template<class T>
void print(const T niz[], const int siz)
{
    for(int i=0;i<siz;i++)
        cout << niz[i] << " ";
    cout << endl;
}

int n,m;
char mat[15][15];
char mat2[15][15];
bool col[15][15];
bool check(int i, int j){
    if(i < 0 || i >= n)
        return 0;
    if(j < 0 || j >= m)
        return 0;
    if(!(mat[i][j] >= '0' && mat[i][j] <= '4'))
        return 0;
    return 1;
}
bool check2(int i , int j){
    if(i < 0 || i >= n)
        return 0;
    if(j < 0 || j >= m)
        return 0;
    if(mat[i][j] == 'C')
        return 1;
    return 0;
}
int brojtopova(int i, int j){
    int br = 0;
    ff(x,-1,1){
        if(x == 0 )
            continue;
        if(check2(i + x, j))
            br++;
        if(check2(i,j + x))
            br++;
    }
    return br;
}
bool sused(int i, int j){
    ff(x,-1,1){
        if(x == 0)
            continue;
        if(check(i + x,j)){
            int k = brojtopova(i + x, j);
            if(k > mat[i + x][j] - '0')
                return 0;
        }
        if(check(i ,j + x)){
            int k = brojtopova(i, j + x);
            if(k > mat[i][j + x] - '0')
                return 0;
        }
    }
    return 1;
}
bool bio[15][15];
bool provera(){
    ff(i,0,n-1){
        ff(j,0,m-1){
            bio[i][j] = 0;
            if(mat[i][j] >= '0' && mat[i][j] <= '4'){
                if(brojtopova(i,j) != mat[i][j] - '0')
                    return 0;
            }
        }
    }
    ff(i,0,n-1){
        ff(j,0,m-1){
            if(mat[i][j] == 'C'){
                int br = i + 1;
                while(br < n && (mat[br][j] == '.' || mat[br][j] == 'C')){
                    bio[br][j] = 1;
                    if(mat[br][j] == 'C')
                        return 0;
                    br++;
                }
                br = i - 1;
                while(br >= 0 && (mat[br][j] == '.' || mat[br][j] == 'C')){
                    bio[br][j] = 1;
                    if(mat[br][j] == 'C')
                        return 0;
                    br--;
                }
                br = j + 1;
                while(br < m && (mat[i][br] == '.' || mat[i][br] == 'C')){
                    bio[i][br] = 1;
                    if(mat[i][br] == 'C')
                        return 0;
                    br++;
                }
                br = j - 1;
                while(br >= 0 && (mat[i][br] == '.') || mat[i][br] == 'C'){
                    bio[i][br] = 1;
                    if(mat[i][br] == 'C')
                        return 0;
                    br--;
                }
            }
        }
    }
    ff(i,0,n-1){
        ff(j,0,m-1){
            if(mat[i][j] == '.' && bio[i][j] == 0)
                return 0;
        }
    }
    return 1;
}

void resi(int i, int j){
    if(i == n  && j == m){
        bool x = provera();
        /*ff(i,0,n-1){
                ff(j,0,m-1){
                    cout << mat[i][j];
                }
                cout << endl;
        }
        cout << endl << endl << endl;*/
        if(x){
            ff(i,0,n-1){
                ff(j,0,m-1){
                    cout << mat[i][j];
                }
                cout << endl;
            }
            exit(0);
        }
        return;
    }
    if(j == m){
        resi(i + 1, 0);
        return;
    }
    if(col[i][j]){
        resi(i, j + 1);
        return;
    }
    if(mat[i][j] != '.'){
        resi(i, j + 1);
        return;
    }
    //stavi
    mat[i][j] = 'C';
    bool ok = sused(i, j);
    if(!ok){
        mat[i][j] = '.';
        resi(i, j + 1);
        return;
    }
    int prvoj = j + 1;
    while(j < m && mat[i][prvoj] == '.')
        prvoj++;
    int br = i + 1;
    while(br < n && mat[br][j] == '.'){
        col[br][j] = 1;
        br++;
    }
    resi(i,prvoj);
    br = i + 1;
    while(br < n && mat[br][j] == '.'){
        col[br][j] = 0;
        br++;
    }
    mat[i][j] = '.';
    resi(i, j + 1);
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    int br = 0;
    ff(i,0,n-1){
        string x;
        cin >> x;
        ff(j,0,m-1){
            if(x[j] != '.')
                br++;
            mat[i][j] = x[j];
        }
    }
    resi(0,0);
    cout << -1 << endl;
    return 0;
}