Bangles is preparing to go on a tour of her local museum. The museum is made up of N rooms in a row, numbered from 1 to N from left to right. The rooms are connected by N-1 locked doors, each connecting a pair of adjacent rooms. Each door has a difficulty level indicating how difficult it is for Bangles to open the door. No two doors will have the same difficulty level. The door between the -th room and -th room has difficulty level .
Bangles will pick one of the rooms to start in, and visit each of the rooms in the museum one at a time, taking pictures as she goes. She takes a picture in her starting room, then she repeats the following procedure until she has taken a picture in all the rooms: Of the two locked doors available to her, she will open the door with the lower difficulty level and take a picture in the newly unlocked room. If there is only one locked door available to her, then she will unlock that door. Once a door is unlocked, it remains unlocked.
Bangles is not yet sure which room she would like to start in, so she needs you to answer queries. For the -th query, she would like to know: What is the -th room that she will take a picture in if she starts in the -th room?
输入格式
The first line of the input gives the number of test cases, . test cases follow. The first line of each test case contains the two integers and . The second line contains integers, describing the locked doors. The -th integer (starting from 1) is . Then, lines follow, describing the queries. The -th of these lines contains the two integers and .
输出格式
For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is a list of the answers for the queries in order, separated by spaces.