This is what the trees in the first and second test cases look like, respectively.
:::align{center}
:::
Consider the first test case.
For , both xor values can be obtained. For example, the set is valid and has xor . And the set is also valid and has xor . Therefore, .
For , both xor values can also be obtained. For example, the set is valid because together with vertex all vertices in its subtree are chosen. Its xor is . And the set is also valid because together with vertex all vertices in its subtree are chosen. Its xor is . Therefore, .
Thus, the answer for the first test case is .
Consider the second test case.
In this test case, both xor values can be obtained only for .
For example, the set is valid. Its xor is .
And the set is also valid. Its xor is . Therefore, .
Thus, the answer for the second test case is .
Scoring
A leaf is a vertex that has no children.
A bamboo is a tree in which every vertex has at most one child.
( points): ;
( points): ;
( points): ;
( points): ;
( points): the total number of leaves over all test cases does not exceed ;
( points): after removing vertex , each component is a bamboo, and there are at most two such components;
( points): after removing vertex , each component is a bamboo;
( points): all trees are full binary trees, that is, for some integer , and for every vertex we have ;