Colorful Village
시간 제한2초메모리 제한1024 MB
각 색이 정확히 두 번씩 나타나도록 색칠된 2n개 정점의 트리에서, 모든 색을 하나씩 포함하는 연결된 n개 정점 집합을 찾거나 존재하지 않음을 판정한다.
문제
Colorful Village is a popular tourist destination. It has houses, numbered from to . Every house has one of colors, numbered from to . Coincidentally, for each of the colors, exactly two houses are colored into it.
There are bidirectional roads in Colorful Village. Each road connects two different houses, and it is possible to reach any house from any other house using these roads.
Catherine is planning a trip to Colorful Village. Her time is limited, so she wants to choose a set of houses to visit, with exactly one house of each color. However, since Catherine also needs to move between houses, the set of houses she is going to visit must be connected. In other words, it must be possible to reach any house in from any other house in using the roads, and only visiting houses in on the way.
Help Catherine to find a connected set of houses, one of each color, or report that no such set exists.
입력
Each test contains multiple test cases. The first line contains the number of test cases (). The description of the test cases follows.
The first line of each test case contains a single integer ().
The second line contains integers , denoting the colors of the houses in Colorful Village (). Every integer from to appears exactly twice in this line.
The -th of the following lines contains two integers and , denoting the houses connected by the -th road (; ).
It is guaranteed that the sum of over all test cases does not exceed .
출력
For each test case, print a single integer if the required set of houses does not exist.
Otherwise, print distinct integers in any order, denoting a connected set of houses, one of each color (). If there are multiple answers, print any of them.