Need help in question Aviroop and XOR Graph (XORGRAPH)

Question Link
I am getting the wrong answer in this question. Here is my submission

This question is almost the same as this question except for the query part.

I am able to get the AC in this question. This code should also work in this question as well but I am getting WA. Can you please help me where I might be wrong here?



WA in here and almost the same code AC here .