Walking Around
시간 제한1초메모리 제한2048 MB
가중치가 있는 트리에서 임의의 단순 경로가 가질 수 있는 간선 가중치 XOR의 최솟값과 최댓값을 구한다.
문제
You are given a weighted tree with vertices, numbered from to . The edges are numbered from to , where edge connects two vertices and with a weight of a non-negative integer .
A path in the tree is defined as a sequence of unique vertices for some such that each pair of adjacent vertices, for all , is connected by an edge in the tree. Define the score of a path as the bitwise XOR of the weight of all edges in the path, i.e. where is the weight of the edge that connects and (for all ).
Your task is to find the minimum and the maximum score of any path that can be obtained from the given tree.
For example, the minimum and the maximum score of any path in the following tree are path with a score of , and path with a score of , respectively.

입력
Input begins with an integer () representing the number of vertices in the given tree. Each of the next lines contains three integers (; ) representing edge .
출력
Output two space-separared integers in a single line, representing the minimum and the maximum score of any path that can be obtained from the given tree in that order.