BFS SHORTEST PATH

sir why code failing test but the answer is correct

4 2
1 2
1 3
2
consider this
the answer should be
6 12 -1
your code gives
6 42 -1
why?
g[e]=(g[key]+1)*6;
due to this line
when in bfs for 1
it goes to 3
g[3] becomes (6 +1)*6
because g[1] = 6
but that is incorrect
what u should do is multiply 6 while prinitng and not while storing