Consider a tree with
nodes numbered from 1 to
,
rooted at 1. Each node
has a natural label
.
Given two nodes
and
,
define
as the exclusive or (^ in C++) of all the
in the path from
to
.
Let be the set of leaves of the tree. Please compute .
Input consists of several trees, each with the number of nodes , followed by , followed by pairs of nodes describing the edges of the tree. Assume , and .
For each tree, print the required sum.
Input
3 2 7 3 1 2 2 3 6 18 6 9 12 15 3 1 6 6 5 3 6 2 3 3 4 7 1 2 3 4 5 6 7 1 4 1 5 2 1 4 6 2 3 2 7 4 1000000000 0 0 0 2 1 3 1 4 1
Output
6 80 11 3000000000