# [Solution] XOR Tree solution codeforces

XOR Tree solution codeforces – You are given a tree consisting of 𝑛n vertices. A number is written on each vertex; the number on vertex 𝑖i is equal to 𝑎𝑖ai.

## [Solution] XOR Tree solution codeforces

Recall that a simple path is a path that visits each vertex at most once. Let the weight of the path be the bitwise XOR of the values written on vertices it consists of. Let’s say that a tree is good if no simple path has weight 00.

You can apply the following operation any number of times (possibly, zero): select a vertex of the tree and replace the value written on it with an arbitrary positive integer. What is the minimum number of times you have to apply this operation in order to make the tree good?

Input

The first line contains one integer 𝑛n (1𝑛21051≤n≤2⋅105) — the number of vertices.

The second line contains 𝑛n integers 𝑎1a1𝑎2a2, …, 𝑎𝑛an (1𝑎𝑖<2301≤ai<230) — the numbers written on vertices.

Then 𝑛1n−1 lines follow, each containing two integers 𝑥x and 𝑦y (1𝑥,𝑦𝑛;𝑥𝑦1≤x,y≤n;x≠y) denoting an edge connecting vertex 𝑥x with vertex 𝑦y. It is guaranteed that these edges form a tree.

## [Solution] XOR Tree solution codeforces

Print a single integer — the minimum number of times you have to apply the operation in order to make the tree good.

Examples
input

Copy
6
3 2 1 3 2 1
4 5
3 4
1 4
2 1
6 1

output

Copy
2

input

Copy
4
2 1 1 1
1 2
1 3
1 4

output

Copy
0


## [Solution] XOR Tree solution codeforces

input

Copy
5
2 2 2 2 2
1 2
2 3
3 4
4 5

output

Copy
2

Note

In the first example, it is enough to replace the value on the vertex 11 with 1313, and the value on the vertex 44 with 4242.