There is a long hot water pipe consisting of sections, each with a capacity of
unit volume. The
sections are numbered
to
from the left to the right to match the direction of water flow in the pipe.
The initial temperature of the water in section is
and it will drop by
unit every minute. To keep the water warm enough, once the temperature of the water in a section is lower than
, it will be heated to
immediately (the heating time can be ignored). When the water in the
-th section is used, the water in the
-th section will move to the
-th section for all
(note that the movements will be completed immediately which means the temperature of the water will not change), and the hot water of temperature
will be added to section
at the same time. Please note that heat transfer effects are not considered in this problem.
Now, there are operations using hot water. Each operation can be described as two integers
, denoting using
units volume of water after
minutes since the last operation (or since the initial time if it is the first operation). Note that the operation is completed immediately. Please output
for every operation, where
stands for the average temperature of the water used. It can be shown that
must be an integer.
The first line of the input contains four integers
![]()
.
The second line contains
intergers, indicating
![]()
respectively.
Each of the next
lines contains two integers
![]()
, indicating an operation using
units volume of water after
minutes since the last operation.
For each operation, output a line containing an integer representing your answer.
Explanation of example:
When the first operation was performed, the temperature of water in section
is
respectively, therefore the answer is
.
When the second operation was performed, the temperature of water in section
is
respectively, therefore the answer is
.
When the third operation was performed, the temperature of water in section
is
respectively, therefore the answer is
.
When the fourth operation was performed, the temperature of water in section
is
respectively, therefore the answer is
.