Unique Color
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Given a tree with vertices numbered through . The -th edge connects Vertex and Vertex . Vertex is painted in color (in this problem, colors are represented as integers).
Vertex is said to be good when the shortest path from Vertex to Vertex does not contain a vertex painted in the same color as Vertex , except for Vertex itself.
Find all the good vertices.
Input
The first line contains the number of vertices . The second line contains colors . Each of the next lines contains two integers and .
Output
Print all good vertices as integers, in ascending order. Print each number on a separate line.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 329
Acceptance rate 48%