A big reservoir was built in Red river using a dam. Assume that the reservoir is a rectangular box with unit length width. The reservoir consists of many tanks. An example a cross section of an empty reservoir along its length and height dimensions is shown in the picture below:
Water flows in from the top left gate into the reservoir. The tanks in the reservoir are constructed using water resistant walls. Each wall is one unit lenght thick (along the width dimension) and has its height smaller than the height of the reservoir.
Given the location and the height of the walls and the unit volume $K$ of water flowing in, your task is to figure out the last wall water flows over.
The input consists of several datasets. The first line of the input contains the number of datasets, which is a positive number and is not greater than $20$. The following lines describe the datasets.
Each dataset is described by the following lines:
The first line contains one positive integers $N$ - the number of walls separating the tanks $(N \leq {10}^{5})$
The second line contains $N$ positive integers ${L}_{i}$- the horizontal location (along the length dimension of the reservoir) of the ${i}^{th}$ wall $(1 \leq {L}_{i} \leq {10}^{9}, {L}_{i} > {L}_{i-1} + 1$ for $i > 1)$.
The third line contains $N$ positive integers ${H}_{i}$ - the height in unit length of the ${i}^{th}$ wall $(1 \leq {H}_{i} \leq {10}^{5})$.
The fourth line contains an integer $Q$ - the number of queries $(Q \leq {10}^{5})$.
In the next $Q$ lines, each line contains a positive integer $K$ that is the unit volume of water flowing in the reservoir $(K \leq {10}^{15})$.
For each dataset, write in $Q$ lines where the ${i}^{th}$ contains the index of the last wall that water flows over for the ${i}^{th}$ query. If there is no wall that water flows over, output $0$.
Sample Input 1 | Sample Output 1 |
---|---|
1 4 1 3 5 8 2 5 3 1 3 3 13 17 |
1 1 3 |