#P7502. [2017年杭电多校]Build a tree
[2017年杭电多校]Build a tree
Build a tree
Problem Description
HazelFan wants to build a rooted tree. The tree has nodes labeled to , and the father of the node labeled is the node labeled . HazelFan wonders the size of every subtree, and you just need to tell him the XOR value of these answers.
Input
The first line contains a positive integer , denoting the number of test cases. For each test case: A single line contains two positive integers .
Output
For each test case: A single line contains a nonnegative integer, denoting the answer.
Sample Input
2
5 2
5 3
Sample Output
7
6
Source
2017 Multi-University Training Contest - Team 7