public class Testing {
static void Allpaths(String P,boolean maze[][],int r, int c){
if(r==maze.length-1 && c==maze[0].length-1){
System.out.println(P);
return;
}
if(maze[r][c]==false){
return;
}
maze[r][c]=false;
if(r<maze.length-1){
Allpaths(P+"D", maze, r+1, c);
}
if(c<maze[0].length-1){
Allpaths(P+"R", maze, r, c+1);
}
if(c>0){
Allpaths(P+"L", maze, r, c-1);
}
if(r>0){
Allpaths(P+"U", maze, r-1, c);
}
maze[r][c]=true;
static int count(int r,int c){
if(r==1||c==1){
return 1;
}
int left=count(r-1,c);
int right=count(r,c-1);
int cross=count(r-1,c-1);
return left+right+cross;
}
static void printPath(String p,int r,int c){
if(r==1 && c==1){
System.out.println(p);
return;
}
if(r>1){
printPath(p+"D", r-1, c);
}
if(c>1){
printPath(p+"R", r, c-1);
}
if(r>1 && c>1){
printPath(p+"C", r-1, c-1);
public static void main(String[] args) {
boolean maze[][]={
{true,true,true},
{true,true,true},
{true,true,true}
};
System.out.println(count(3,3));
printPath(" ", 3, 3);
}