Rat chases its cheese 2 wrong answers

I am getting two wrong test cases out of 5. Not able to find the issue.
And is it not a recursion backtracking problem repeated again.

Piyush you are coding incorrectly for the problem. In the problem, it is clearly mentioned that the rat can follow up, down , left and right but while coding you have taken only 2 directions. Plz change your code accordingly and then try to submit.

donw with changes and the infinite condition …
Thanks a lot.