BFS - Shortest Path Doubt

Question link:
https://online.codingblocks.com/app/player/115374/content/73633/5090/code-challenge

Code link:

First Test case is showing wrong answer, second test case is running correctly, can you please help in fixing the error?

hello @mgfags
image
add this one more condition

Got it!!! Thank you so much!!