Unable to pass 2 test cases for the problem Rat Chases its Cheese

I am unable to pass 2 test cases for the above mentioned problem. I can’t find any logical mistake in my approach. Please help

Here is my Code: https://ide.codingblocks.com/s/303527

@Yash5646,
I think you have done something wrong in base cases. Check out my code(Link) for the same problem.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.