Let’s find one possible first. Since the given information of the nodes are symmetric, one should focus on the XOR sum of all the for a specific . One can easily verify that, for , the value is exactly . Additionally, since the only given information of a node is its value, one can arbitrarily choose one whose value matches the desired value.
It can be easily verified that the XOR sum of all is the XOR sum of the value of all nodes except . Therefore, to find , one only needs to find the XOR sum of the value of all nodes. Using the given , one can easily evaluate the XOR sum of the value of the nodes whose distance from one specific node is odd. If one colors the tree in two colors by the parities of the nodes’ depths, or their distances from the root, then two nodes’ distance is odd if and only if they are of different colors. Therefore, the value described above is the same for nodes of the same color, and the XOR sum of the value of two different colored nodes is exactly what is needed. Find all the distint values, and the needed value if is there is only one distinct value, and their XOR sum if there are two distinct values.