#abc258e. [abc258_e]Packing Potatoes

[abc258_e]Packing Potatoes

Problem Statement

1010010^{100} potatoes are coming from a conveyor belt one by one. The weights of the potatoes are described by a sequence W=(W0,dots,WN1)W = (W_0, \\dots, W_{N-1}) of length NN: the weight of the ii-th potato coming is W(i1)bmodNW_{(i-1) \\bmod N}, where (i1)bmodN(i-1) \\bmod N denotes the remainder when i1i - 1 is divided by NN.

Takahashi will prepare an empty box and then pack the potatoes in order, as follows.

  • Pack the incoming potato into the box. If the total weight of the potatoes in the box is now XX or greater, seal that box and prepare a new empty box.

You are given QQ queries. In the ii-th query (1leqileqQ)(1 \\leq i \\leq Q), given a positive integer KiK_i, find the number of potatoes in the KiK_i-th box to be sealed. It can be proved that, under the Constraints of the problem, there will be at least KiK_i sealed boxes.

Constraints

  • 1leqN,Qleq2times1051 \\leq N, Q \\leq 2 \\times 10^5
  • 1leqXleq1091 \\leq X \\leq 10^9
  • 1leqWileq109,(0leqileqN1)1 \\leq W_i \\leq 10^9 \\, (0 \\leq i \\leq N - 1)
  • 1leqKileq1012,(1leqileqQ)1 \\leq K_i \\leq 10^{12} \\, (1 \\leq i \\leq Q)
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN QQ XX W0W_0 W1W_1 ldots\\ldots WN1W_{N-1} K1K_1 vdots\\vdots KQK_Q

Output

Print QQ lines. The ii-th line (1leqileqQ)(1 \\leq i \\leq Q) should contain the answer to the ii-th query.


Sample Input 1

3 2 5
3 4 1
1
2

Sample Output 1

2
3

Before sealing the 22-nd box, Takahashi will do the following:

  • Prepare an empty box.
  • Pack the 11-st potato into the box. Now, the total weight of potatoes in the box is 33.
  • Pack the 22-nd potato into the box. Now, the total weight of potatoes in the box is 3+4=73 + 4 = 7, which is not less than X=5X = 5, so seal this box.
  • Prepare a new empty box.
  • Pack the 33-rd potato into the box. Now, the total weight of potatoes in the box is 11.
  • Pack the 44-th potato into the box. Now, the total weight of potatoes in the box is 1+3=41 + 3 = 4.
  • Pack the 55-th potato into the box. Now, the total weight of potatoes in the box is 1+3+4=81 + 3 + 4 = 8, which is not less than X=5X = 5, so seal this box.

The 11-st box sealed contains 22 potatoes, and the 22-nd box sealed contains 33 potatoes.


Sample Input 2

10 5 20
5 8 5 9 8 7 4 4 8 2
1
1000
1000000
1000000000
1000000000000

Sample Output 2

4
5
5
5
5