The xor-longest Path
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 32 M,其他语言64 M
64bit IO Format: %lld

题目描述

In an edge-weighted tree, the xor-length of a path p is defined as the xor sum of the weights of edges on p:

⊕ is the xor operator.
We say a path the xor-longest path if it has the largest xor-length. Given an edge-weighted tree with n nodes, can you find the xor-longest path?

输入描述:

The input contains several test cases. The first line of each test case contains an integer n, The following n-1 lines each contains three integers ,,, which means there is an edge between node u and v of length w.

输出描述:

For each test case output the xor-length of the xor-longest path.
示例1

输入

复制
4
0 1 3
1 2 4
1 3 6

输出

复制
7