Rat in maze code is not submitting

my code is not submitting its running bt not submitting i dnt knw why??
import java.util.*;
public class Main {
public static int count=0;
public static void ratmaze(char[][] maze,int row,int col,int[][] n)
{
if(row==maze.length&& col==maze[0].length-1)
{
count++;
for(int i=0;i<n.length;i++)
{
for(int j=0;j<n[0].length;j++)
System.out.print(n[i][j]);
System.out.println();
}

		return ;
	}

	if(row==maze.length ||col==maze[0].length || maze[row][col]=='X' ||maze[row][col]=='1'|| count==1)
		return ;
	maze[row][col]='1';
	n[row][col]=1;
	ratmaze(maze,row,col+1,n);
	ratmaze(maze,row+1,col,n);
	
	maze[row][col]='0';
	n[row][col]=0;
		
}
public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	int N=sc.nextInt();
	int M=sc.nextInt();
	char[][] ch=new char[N][M];
	for(int i=0;i<N;i++)
	{	String st="";
		
		if (sc.hasNext()) { // input from user 
			st = sc.next();
			} else {
				break;
			}
		for(int j=0;j<M;j++)
			{
			ch[i][j]=st.charAt(j);
			}
		}
	ratmaze(ch,0,0,new int[N][M]);
	if(count==0)
		System.out.println(-1);
	
	
}

}

Hey @Avnish-Singh-2724104534303277
logic is fine :
Find the rightmost path through which, rat can reach this position.
work for it

sir but it is giving rightmost path

only fro custom input : it is giving rightmost path
in other case print all possible path