
128  The 2013 ACMICPC Asia Changsha Regional Contest  A
Alice is providing print service, while the pricing doesn't seem to be reasonable, so people using her print service found some tricks to save money. For example, the price when printing less than 100 pages is 20 cents per page, but when printing not less than 100 pages, you just need to pay only 10 cents per page. It's easy to figure out that if you want to print 99 pages, the best choice is to print an extra blank page so that the money you need to pay is 100 × 10 cents instead of 99 × 20 cents. Now given the description of pricing strategy and some queries, your task is to figure out the best ways to complete those queries in order to save money. InputThe first line contains an integer T (≈ 10) which is the number of test cases. Then T cases follow. Each case contains 3 lines. The first line contains two integers n, m (0 < n, m ≤ 10^{5}). The second line contains 2n integers s_{1}, p_{1}, s_{2}, p_{2}, ..., s_{n}, p_{n} (0=s_{1} < s_{2} < ... < s_{n} ≤ 10^{9}, 10^{9} ≥ p_{1} ≥ p_{2} ≥ ... ≥ p_{n} ≥ 0). The price when printing no less than s_{i} but less than s_{i+1} pages is p_{i} cents per page (for i=1..n1). The price when printing no less than s_{n} pages is p_{n} cents per page. The third line containing m integers q_{1} .. q_{m} (0 ≤ q_{i} ≤ 10^{9}) are the queries. OutputFor each query q_{i}, you should output the minimum amount of money (in cents) to pay if you want to print q_{i} pages, one output in one line. Sample Input1 2 3 0 20 100 10 0 99 100 Sample Output0 1000 1000 Author: ZHUANG, Junyuan 