#### Жишээ тэстүүд

##### Оролт

4 1 1 1 0 0 1 2 1 3 1 4

##### Гаралт

2

##### Оролт

7 1 1 0 1 1 0 0 0 1 2 1 3 2 4 2 5 3 6 3 7

##### Гаралт

2

## Тэмдэглэл

Let us remind you that a tree$ is a connected graph on $n$ vertices and $n - 1$ edge. A rooted$ tree is a tree with a special vertex called root$. In a rooted tree among any two vertices connected by an edge, one vertex is a parent (the one closer to the root), and the other one is a child. A vertex is called a leaf$, if it has no children.

Note to the first sample test: The vertices containing cats are marked red. The restaurants are at vertices 2, 3, 4. Kefa can't go only to the restaurant located at vertex $2$.

Note to the second sample test: The restaurants are located at vertices 4, 5, 6, 7. Kefa can't go to restaurants 6, 7.