11620 - pD - Distrait   

Description

Eccioa's Japanese teacher sometimes plays Bingo with students in the class. Students will be asked to randomly fill 1~25 in a 5*5 card. Then the teacher asks each of the students to choose a number one by one. The first few students who find the selected numbers are arranged on their card in a row, a column or a diagnose can get snacks that the teacher brought back from Japan as a reward.
 
One day, the teacher started to play Bingo again. But Eccioa zoned out for a minute. When he woke up, there were already N numbers being selected. He wondered if he gets the reward. If so, when did he win?
 

Input

First 5 lines describe the card. Each line contains 5 integers between 1 and 25.

( We guarantee that all 25 numbers are distinct. )

Next line contains an integer T ( 1 <= T <= 100 ), number of testcases.

Following are T testcases, and each of them contains 2 lines.

The first line of each testcase contains an integer N ( 1 <= N <= 25 ), number of selected numbers.

The second line contains N distinct selected numbers, from 1-st to N-th.

Output

For each testcase, print out an integer x, telling eccioa he can get the reward at x-th number, with x as small as possible. If he couldn't, tell him that he did not get the reward yet.

See Sample Output for more information about output format.

Sample Input  Download

Sample Output  Download

Tags




Discuss