##B. Lunar New Year And Food Ordering##
B. Lunar New Year And Food Ordering
The restaurant "Alice's" serves \$n\$ kinds of food. The cost for the \$i\$-th kind is always \$c_i\$. Initially, the restaurant has enough ingredients for serving exactly \$a_i\$ dishes of the \$i\$-th kind. In the New Year's Eve, \$m\$ customers will visit Alice's one after another and the \$j\$-th customer will order \$d_j\$ dishes of the \$t_j\$-th kind of food. The \$(i+1)\$-st customer will only come after the i-th customer is completely served.
Suppose there are \$r_i\$ dishes of the \$i\$-th kind remaining (initially \$r_i = a_i\$). When a customer orders \$1\$ dish of the \$i\$-th kind, the following principles will be processed.
- If \$r_i > 0\$, the customer will be served exactly \$1\$ dish of the \$i\$-th kind. The cost for the dish is \$c_i\$. Meanwhile, \$r_i\$ will be reduced by \$1\$.
- Otherwise, the customer will be served \$1\$ dish of the cheapest available kind of food if there are any. If there are multiple cheapest kinds of food, the one with the smallest index among the cheapest will be served. The cost will be the cost for the dish served and the remain for the corresponding dish will be reduced by \$1\$.
- If there are no more dishes at all, the customer will leave angrily. Therefore, no matter how many dishes are served previously, the cost for the customer is \$0\$.
If the customer doesn't leave after the \$d_j\$ dishes are served, the cost for the customer will be the sum of the cost for these \$d_j\$ dishes.
Please determine the total cost for each of the \$m\$ customers.
###Input###
Input
The first line contains two integers \$n\$ and \$m\$ (\$ 1 ≤ n, m ≤ 10^5\$), representing the number of different kinds of food and the number of customers, respectively.
The second line contains \$n\$ positive integers \$a_1, a_2,\ldots, a_n\$ (\$1 ≤ a_i ≤ 10^7\$), where \$a_i\$ denotes the initial remain of the \$i\$-th kind of dishes.
The third line contains \$n\$ positive integers \$c_1, c_2, \ldots, c_n\$ (\$1 ≤ c_i ≤ 10^6\$), where \$c_i\$ denotes the cost of one dish of the \$i\$-th kind.
The following \$m\$ lines describe the orders of the \$m\$ customers respectively. The \$j\$-th line contains two positive integers \$t_j\$ and \$d_j\$ (\$1 ≤ t_j ≤ n\$, \$1 ≤ d_j ≤ 10^7\$), representing the kind of food and the number of dishes the \$j\$-th customer orders, respectively.
###Output###
Output
Print \$m\$ lines. In the \$j\$-th line print the cost for the \$j\$-th customer.
###Requirements###
Requirements
- time limit per test: 2 seconds
- memory limit per test: 256 megabytes
- input: standard input
- output: standard output