Problem: You are given a tree of nodes, rooted at . Every node has a value of either or at time .
At any integer time , the value of a node becomes the bitwise XOR of the values of its children at time ; the values of leaves become since they don't have any children.
Let denote the sum of values of all nodes at time .
Let denote the sum of across all values of such that , where is the initial assignment of s and s in the tree.
The task is to find the sum of for all initial configurations of s and s in the tree. Print the sum modulo .
Input Format: Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains () — the number of nodes in the tree.
The next lines of each test case contain two integers each — , indicating an edge between and ().
It is guaranteed that the sum of over all test cases does not exceed .
Output Format: Output the sum modulo for each test case.
Note: Let us find for the configuration ( denotes the value of node ). Initially (at ) our tree is as shown in the picture below. In each node, two values are shown: the number and the value of this node. for this configuration is .
At the configuration changes to . The tree looks as shown below. .
At the configuration changes to . The tree looks as shown below. .
For all , the graph remains unchanged, so for all . So, for the initial configuration , the value of .
Doing this process for all possible configurations yields us an answer of .