XOR pairs#11774

XOR pairs

Given a tree with vertices, with root at vertex . Each vertex has value a_v. For each vertex find any distinct indices (i, j, k, l) where a_i \oplus a_j = a_k \oplus a_l and (i, j, k, l) are on the path from the root to .

Input

The first line contains one integer, (1 \le n \le 10^5) — the number of vertices.

The second line contains integers, a_1, a_2, \dots, a_n (0 \le a_i < 2^{18}) — the value of the -th vertex.

Each of the next n-1 lines contains two integers , (1 \le x, y \le n) — two vertices which are connected by edge.

Output

Print lines. In -th line print answer for -th vertex or four if there is no answer.

Examples

Example 1

Loading
Loading

Note

Scoring

  1. ( points): n\le 10^3;

  2. ( points): tree is a chain;

  3. ( points): a_i is a power of 2;

  4. ( points): no additional constraints.