There is a tree which contains n nodes, of course it has n - 1 edges, with weight.
Now the problem is, finding the number of (a, b) that the exclusive-xor sum of the edges between a to b is zero. Note that (a, b) is equal to (b, a).
Since the answer is very large, output it after module 1000, 000, 007.
1 5 1 2 3 1 3 3 2 4 4 3 5 4
7
In the example, the seven pair nodes are (1, 1)、(2, 2) 、(3, 3)、 (4, 4) 、(5, 5)、 (2, 3) and (4, 5).
Alex@NBUT