Competitions

# Trees: Depth First Search

# Unique Color

Given a tree with **n** vertices numbered **1** through **n**. The **i**-th edge connects Vertex `a`

and Vertex _{i}`b`

. Vertex _{i}**i** is painted in color `c`

(in this problem, colors are represented as integers)._{i}

Vertex **x** is said to be **good** when the shortest path from Vertex **1** to Vertex **x** does not contain a vertex painted in the same color as Vertex **x**, except Vertex **x** itself.

Find all good vertices.

#### Input

The first line contains number of vertices **n** (**2** ≤ **n** ≤ `10`

). The second line contains colors ^{5}`c`

, _{1}`c`

, ..., _{2}`c`

(_{n}**1** ≤ `c`

≤ _{i}`10`

). Each of the next ^{5}**n** - **1** lines contains two integers `a`

and _{i}`b`

(_{i}**1** ≤ `a`

, _{i}`b`

≤ _{i}**n**).

#### Output

Print all good vertices as integers, in ascending order. Print each number in a separate line.

Input example #1

6 2 7 1 8 2 8 1 2 3 6 3 2 4 3 2 5

Output example #1

1 2 3 4 6

Input example #2

10 3 1 4 1 5 9 2 6 5 3 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10

Output example #2

1 2 3 5 6 7 8