Getting WA for all the subtasks of FCTRE of April Long Challenge 2020

I am getting WA for all the subtasks of FCTRE of April long challenge .
My solution link is: CodeChef: Practical coding for everyone
Can anyone please help me suggest a test case for which my solution is giving Wrong Answer or suggest the error in my logic or any other error in my code…

Input
1
4
1 2
1 3
4 2
11 17 17 29
2
1 4
2 3

Output
1
16

Expected Output
8
6

hope you can figure out why…this is giving wrong answer

oh…thanks a lot for helping me figure out my error :pray:
And also thank you for responding to my query…

1 Like