You have a tree consisting of N vertices. Print the number of Pairs of nodes that are at an even distance.
The First line contains an integer T, the number of testcases.
The first line of each testcase contains an integer N , the total number of vertices.
The second line contains 2*(N-1) space-separated vertices (u and v) connecting nodes in the tree.
Print the total number of pairs having even distance between them.
1<= N <=10000
1<= u, v <=N
1 3 1 2 2 4 3 5
There are pairs with even distance between them:
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.