P9784 [ROIR 2020] Speeding (Day1)

Description

**Translated from [ROIR 2020](http://neerc.ifmo.ru/school/archive/2019-2020.html) Day1 T2.** ***[Превышение скорости](http://neerc.ifmo.ru/school/archive/2019-2020/ru-olymp-regional-2020-day1.pdf)***, translated by ShineEternal. Speeding is a dangerous illegal behavior that greatly increases the chance that traffic accidents lead to tragic consequences. Unfortunately, controlling speed using radar and cameras cannot completely solve the problem. To prevent this behavior, one can limit speeding by imposing fines based on the time a car spends on a section of road. Now there are $n$ road segments numbered from $1$ to $n$. Segment $i$ has length $l_i$ meters, and its speed limit is $v_i$ meters per second. Speeding will be fined, but to reflect “pay according to work”, different levels of speeding have different fine amounts. Specifically, if the car does not speed, then there is no fine. Otherwise, let $e$ be the value of **the car’s maximum speed on this segment minus the speed limit**: - If $0

Input Format

The first line contains a positive integer $n$, the number of road segments. The next two lines each contain $n$ numbers: the first line is $v_i$, and the second line is $l_i$. The fourth line contains a positive integer $m$, the number of the $m$ different fine ranges. The next two lines: the first line contains $m-1$ numbers, which are $a_i$; the second line contains $m$ numbers, which are $f_i$. The seventh line contains a positive integer $q$, the number of cars. The next $q$ lines each contain two integers $s_i,t_i$.

Output Format

Output $q$ lines in total. For each car, output the minimum fine amount it must be charged.

Explanation/Hint

For $100\%$ of the testdata, $1\leq n\leq 10$, $1\leq v_i,l_i,a_i,f_i\leq 10^9$, $1\leq m\leq 10^5$, $1\le q\le 10^5$, $1\leq s_i