XorTree

아직 제출이 없습니다시간 제한2초메모리 제한256 MB

문제

You are given a tree with NN vertices. The vertices are numbered 00 through N1N-1, and the edges are numbered 11 through N1N-1. Edge ii connects vertex x_ix\_i and y_iy\_i, and has a value a_ia\_i. You can perform the following operation any number of times: choose a simple path and a non-negative integer xx, then for each edge ee that belongs to the path, change a_ea\_e by executing a_e:=a_exa\_e := a\_e \oplus x (\oplus denotes XORXOR).

Your objective is to have a_e=0a\_e = 0 for all edges ee. Find the minimum number of operations required to achieve it.

입력

Input is given in the following format:

NN

x_1x\_1 y_1y\_1 a_1a\_1

x_2x\_2 y_2y\_2 a_2a\_2

\ldots

x_N1x\_{N-1} y_N1y\_{N-1} a_N1a\_{N-1}

출력

Find the minimum number of operations required to achieve the objective.

제한

2N1052 \le N \le 10^5, 0x_i,y_iN10 \le x\_i,y\_i \le N-1, 0a_i150 \le a\_i \le 15. The given graph is a tree, all input values are integers.

힌트

In Sample 1, the objective can be achieved in three operations, as follows: first, choose the path connecting Vertex 1,21, 2, and x=1x = 1, then, choose the path connecting Vertex 2,32, 3, and x=2x = 2; lastly, choose the path connecting Vertex 0,40, 4, and x=4x = 4.