#SAS003. Apoorv Loves Primes

Apoorv Loves Primes

Given two arrays A and B of size n and x. Apoorv is given an empty array P. He has to fill the array according to the following conditions:

for each i in range (0 to x-1) {
    if b[i] is negative
        (insert the subarray from A[abs(B[i]] to A[n-1] in P at the end)
    else
        (insert the subarray from A[0]to A[B[i]] in P at the end)
}

Since Apoorv loves Prime numbers He wants to know the Kth prime number in P after the above operation is completed.

So given q queries Apoorv has to report the kth prime number in it. If kth prime doesn't exist print -1.

Note: Both A and B are 0 indexed. abs stands for absolute value.

Constraints:

1<=n<=100000

1<=x<=100000

1<=A[i]<=1000000

0<=abs(B[i])<=n-1

1<=q<=10000

1<=k<=10000000000

Input

First line will contain n size of A.

Second line will contain n space separated integers denoting A[i].

Third line will contain x denoting size of B.

Fourth line will contain x space separated integers denoting B[i].

Fifth line will contain q denoting number of queries.

Sixth line will contain q space separated integers denoting k.

Output

Print q lines denoting output for each query.

Example

Input:
3
2 3 4
1
2
3
1 2 3

Output: 2 3 -1

</p>
Explanation:

P is [2,3,4] so for k=1 answer is 2, for k=2 answer is 3, for k=3 answer=-1 because 3rd prime number doesn't exist.