Wrong answer in bfs shortest path

why ans is showing wrong on this online editor but it is giving
correct results for the given test cases in the question.
please check my code i don’t think it have any conceptual error

please share your code so that I can figure out the mistake.

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.