Bfs shortest path ques

i am unable to find why it is giving runtime error while running for two or more test cases pls optimise it
link to code is https://ide.codingblocks.com/s/115134