Time Limit: 2000/1000 MS (Java/Others)

Memory Limit: 32768/32768 K (Java/Others)

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.

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.

The 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..n-1). 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.

Each case contains 3 lines. The first line contains two integers n, m (0 < n, m ≤ 10

提交代码