UPDATEIT - Update the array !

You have an array containing n elements initially all 0. You need to do a number of update operations on it. In each update you specify l, r and val which are the starting index, ending index and value to be added. After each update, you add the 'val' to all elements from index l to r. After 'u' updates are over, there will be q queries each containing an index for which you have to print the element at that index.

Input

First line consists of t, the number of test cases. (1 <= t <= 10)

Each test case consists of "n u", number of elements in the array and the number of update operations, in the first line (1 <= n <= 10000 and 1 <= u <= 100000)

Then follow u lines each of the format "l r val" (0 <= l, r < n, 0 <= val <=10000)

Next line contains q, the number of queries. (1 <= q <= 10000)

Next q lines contain an index (0 <= index < n)

Output

For each test case, output the answers to the corresponding queries in separate lines.

Example

Input:
1
5 3
0 1 7
2 4 6
1 3 2
3
0
3
4

Output:
7
8
6

Added by:Pandian
Date:2013-10-15
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own

hide comments
2014-09-29 20:21:04 Vidur Katyal



Last edit: 2014-10-20 17:17:05
2014-08-06 15:04:24 j1k7_7(JaskamalKainth)
BIT it is.:D
2014-07-19 17:54:58 Ranjan Kumar Singh
similar to codechef INTEG sept2013 long challenge problem
2014-07-12 20:18:49 Archit Jain
easy
2014-07-01 17:18:47 sobriquet
Simple Segment Tree. Without fast I/O--1.92 sec.
2014-06-18 10:43:03 Pallav Roy
soln id 11781458. why am i getting TLE on this?
2014-03-31 23:33:54 pk
my first BIT :)
no need of fast io
2014-03-31 16:46:10 Rishabh Dugar
phew..fast io must
2014-02-07 14:54:00 Bhavik
learnt the concept behind BIT...:)
and arrays are sufficient..
2014-02-02 10:40:15 zingoba
This could be moved to the tutorial section. Guess we already have plenty of similar problems in the classical section.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.