#include<bits/stdc++.h>
using namespace std;
bool ratinmaze(char in[10][10],int sol[][10],int i,int j,int m,int n){
if(i==m and j==n){
sol[i][j]=1; // prints all the solutions of the maze
for(int k=0;k<=m;k++){
for(int l=0;l<=n;l++){
cout<<sol[k][l]<<" ";
}
cout<<endl;
}
cout<<endl;
return true;
}
if(in[i][j]==‘X’){
return false;
}
if(i>m ||j>n){
return false;
}
sol[i][j]=1;
//recursive function
bool moveright=ratinmaze(in,sol,i,j+1,m,n);
bool movedown=ratinmaze(in,sol,i+1,j,m,n);
//backtracking
sol[i][j]=0;
if(moveright||movedown){
return true;
}
return false;
}
int main(){
int m,n;
cin>>m>>n;
char in[10][10];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>in[i][j];
}
}
int sol[10][10]={0};
bool ans=ratinmaze(in,sol,0,0,3,3);
if(ans==false){
cout<<“no possible path”;
}
return 0;
}