#include<bits/stdc++.h>
using namespace std;;
bool hasPath(vector grid, vector<vector> &path,int i, int j){
if(grid[i][j]==‘X’){
return false;
}
if(i==grid.size()-1 && j==grid[0].size()-1){
path[i][j]=true;
return true;
}
if(j<grid[0].size()-1 && hasPath(grid,path,i,j+1)){
path[i][j]=true;
return true;
}
else if(i<grid.size()-1 && hasPath(grid,path,i+1,j)){
path[i][j]=true;
return true;
}
else{
return false;
}
}
int main() {
int n,m;
cin>>n>>m;
vector grid;
for(int i=0;i<n;i++){
string temp;
cin>>temp;
grid.push_back(temp);
}
vector<vector> path(n,vector(m,false));
bool check=hasPath(grid,path,0,0);
if(check){
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(path[i][j]){
cout<<"1 ";
}
else{
cout<<“0 “;
}
}
cout<<endl;
}
}
else{
cout<<”-1”<<endl;
}
return 0;
}