Your boss is sending you out on an international sales trip. What joy!
You have cities (numbered from to ) to visit and can get to them using a set of bidirectional flights that go between the cities.
All of the cities must be visited at least once. To do this you can book any number of tickets, subject to the following conditions:
Each ticket consists of flights, one from a specific city to another specific city (this is called the outbound flight), and the other one from city to city (this is called the return flight).
You must use the outbound flight before the corresponding return flight (you can use other flights in between).
At most outbound flight going to each city, although there is no limit on the return flights (multiple return flights can go to the same city).
You must use all flights which belong to the tickets you booked.
You can otherwise visit the cities in any order you like.
You can start your trip from any city you choose. You may not take an outbound flight to your starting city.
Now you could try to minimize the total distance travelled, but you did that last time, so that would be boring. Instead you noticed that each city has a distinct digit ZIP (postal) code. When you visit a city for the first time (this includes the city which you start from) you write down the zip code and concatenate these into one large number (concatenate them in the order which you visited each city for the first time). What is the smallest number you can achieve?
输入格式
The first line of the input gives the number of test cases, . test cases follow.
Each test case starts with a single line containing two integers: the number of cities and the number of possible bidirectional flights .
lines then follow, with the -th line containing the -digit zip code of the -th city. No ZIP code will have leading zeros and all ZIP codes in each test case will be distinct.
lines then follow, each containing two integers and () indicating that a bidirectional flight exists between the -th city and the -th city. All flights will be distinct within each test case.
It is guaranteed that you can visit every city following the rules above.
输出格式
For each test case, output one line containing "Case #: ", where is the test case number (starting from ) and is the smallest number you can achieve by concatenating the ZIP codes along your trip.