404245: GYM101466 J Jeronimo's List

Memory Limit:1024 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Jeronimo's Listtime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard output

Jeronimo the bear loves numbers and he is planning to write n numbers in his notebook.

After writing the first m numbers, Jeronimo felt that he was spending a lot of time thinking new numbers, so he wrote the next n - m missing numbers as the sum modulo 3 × 107 of the numbers in the i - m and i - m + 1 positions for m < i ≤ n

While Jeronimo was writing, his sister Lupe arrived and asked him q questions. The i - th question consist of a number bi, Jeronimo has to say what would be the number in the position bi if all the numbers were sorted in ascending order. Jeronimo wants to answer each question as soon as possible but he spends a lot of time counting so he ask your help.

Input

The first line of the input has three integers n (3 ≤ n ≤ 3 × 107), m (3 ≤ m ≤ min(100, n)) and q (1 ≤ q ≤ 10000).

The second line contains m numbers a1, a2, ..., am, (0 ≤ ai < 3 × 107), The first m numbers that Jeronimo wrote.

The third line contains q questions b1, b2, ..., bq (1 ≤ bi ≤ n)

Output

Print q lines. The i - th line must be the answer of the i - th question made by Lupe.

ExamplesInput
6 3 6
1 2 3
1 2 3 4 5 6
Output
1
2
3
3
5
6
Input
10 4 3
1 2 9 10
1 5 10
Output
1
10
30

加入题单

算法标签: