In a quaint forest, a magnificent tree with N vertices, each connected by N−1 enchanting edges where each edge has some value.
The goal is to count the number of simple paths having the following intriguing properties:
Note: A simple path is a path in a tree that does not have repeating vertices. A simple path from node u to node v is considered different than a simple path from node v to node u.
Input format
Output format
For each test case, print the number of simple paths having the aforementioned intriguing properties in a new line.
Constraints
1≤T≤1053≤N≤1061≤u,v≤N0≤w≤109The sum of all values of N over all test cases doesn't exceed 106
The first line denotes T = 1.
For test case 1:
We are given:
Now, the simple paths that have an odd number of edges and an even number of set bits (1's) in the Bitwise XOR result of all the edge values on the simple path are as follows
Therefore, the answer is 6.