#include
using namespace std;
int sol[100][100]={0};
bool ratinmaze(char a[][100],int i,int j,int n,int m){
//base case
if(i==n-1 && j==m-1){
sol[i][j]=1;
for(int k=0;k<n;k++){
for(int l=0;l<m;l++){
cout<<sol[k][l]<<" ";
}
cout<<endl;
}
cout<<endl;
return true;
}
//recursive case
sol[i][j] = 1;
if(j + 1 < m && a[i][j+1] != ‘X’){
bool sok= ratinmaze(a,i,j+1,n,m);
if(sok==true){
return true;
}
}
if(i+1 < n && a[i+1][j] != ‘X’){
bool val= ratinmaze(a,i+1,j,n,m);
if(val==true){
return true;
}
}
sol[i][j]=0;
return false;
}
int main() {
char ans[100][100];
int n,m;
cin>>n;
cin>>m;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>ans[i][j];
}
}
bool k=ratinmaze(ans,0,0,n,m);
if(k==false){
cout<<-1<<endl;
}
}