multiplication-8

Chotu on his new mission has to crack a safe to get intel on "cobalt". The lock is programmed such that it displays N numbers and generates Q queries when someone tries to open it. The safe opens when each query is answered correctly.
For each query the lock displays an index I, the numbers at the I^th index disappears, the answer to the  query  is  the product of remaining numbers on the screen modulo M.
There is not much time left help so Chotu needs your help to crack the safe open.
Note - After each query, the number reappears at the I^th index.
Input
First line of input contains 3 integers N, M and Q , the number of elements, the value of Modulus ans the number of queries.
Next line contains N integers.
Next Q lines contain an integer I, denoting the index of the number that dissapears in the query.

Output
For each query print the answer in a seperate line.

Constraints
1 ≤ N ≤ 10^5
1 ≤ Q ≤ 10^5
1 ≤ M ≤ 10^4
1 ≤ Ai ≤ 10^4
1 ≤ I ≤ N

SAMPLE INPUT
5 6 2
2 4 3 2 5
3
2

SAMPLE OUTPUT
2
0

Explanation

For first query the product of elements after removing the 3rd element will be 2 * 4 * 2 * 5 = 80. So the answer is 80 % 6 = 2.
For 2nd query, the product will be  2 * 3 * 2 * 5 = 60. So answer is 60 % 6 = 0.

Source: hackerearth | Difficulty: EASY


Solutions: