**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?

The first line contains one integer 𝑛n (1≤𝑛≤2⋅1051≤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.

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

2

4 2 1 1 1 1 2 1 3 1 4

0

## [Solution] XOR Tree solution codeforces

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

2

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.