#include <bits/stdc++.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

int n,m,i,j,k;
int a[12][12];
bool resenje=false;

bool ok()
{
	for(i=1;i<=n;i++) for(j=1;j<=m;j++)
	{
		if(a[i][j]<=4)
		{
			k=(a[i+1][j]==6)+(a[i][j+1]==6)+(a[i-1][j]==6)+(a[i][j-1]==6);
			if(a[i][j]!=k) return false;
		}
		else if(a[i][j]==6)
		{
			k=i-1;
			while(k>1 && a[k][j]==7) k--;
			if(a[k][j]==6) return false;
			k=i+1;
			while(k<n && a[k][j]==7) k++;
			if(a[k][j]==6) return false;
			k=j-1;
			while(k>1 && a[i][k]==7) k--;
			if(a[i][k]==6) return false;
			k=j+1;
			while(k<m && a[i][k]==7) k++;
			if(a[i][k]==6) return false;
		}
		else if(a[i][j]==7)
		{
			k=i-1;
			while(k>1 && a[k][j]==7) k--;
			if(a[k][j]==6) continue;
			k=i+1;
			while(k<n && a[k][j]==7) k++;
			if(a[k][j]==6) continue;
			k=j-1;
			while(k>1 && a[i][k]==7) k--;
			if(a[i][k]==6) continue;
			k=j+1;
			while(k<m && a[i][k]==7) k++;
			if(a[i][k]==6) continue;
			return false;
		}
	}
	return true;
}

void ubaci(int x,int y)
{
	if(resenje) return ;
	if(x==n && y==m)
	{
		if(a[x][y]!=7)
		{
			if(ok()) resenje=true; 
			return ;
		}
		a[x][y]=6;
		if(ok())
		{
			resenje=true;
			return;
		}
		a[x][y]=7;
		if(ok()) resenje=true;
		return;
	}
	if(a[x][y]!=7)
	{
		ubaci(x+y/m,y%m+1);
		return ;
	}
	a[x][y]=6;
	ubaci(x+y/m,y%m+1);
	if(resenje) return ;
	a[x][y]=7;
	ubaci(x+y/m,y%m+1);
	return ;
}

int main(int argc, char** argv) {
	int i,j;
	string s;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		cin>>s;
		for(j=1;j<=m;j++)
		{
			if(s[j-1]=='.') a[i][j]=7;
			else if(s[j-1]=='#') a[i][j]=5;
			else a[i][j]=(int)(s[j-1]-'0');
		}
	}
	ubaci(1,1);
	if(!resenje)
	{
		cout<<"-1"<<endl;
		return 0;
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(a[i][j]==7) cout<<".";
			else if(a[i][j]==6) cout<<"C";
			else if(a[i][j]==5) cout<<"#";
			else cout<<(char)('0'+a[i][j]);
		}
		cout<<endl;
	}
	return 0;
}