Masala F

Xotira 32 MB Vaqt 1000 ms
14

Dunes

Geographer Grigory Georgievich is studying the formation of sand dunes. He chose a very long dune and divided it into a huge number of sections, numbering them from 11 to 109.10^9. Grigory Georgievich's theory states that initially the height of the sand relative to some arbitrary mark on all sections was zero. After that, there were n strong gusts of wind that could alter the landscape. Wind gust number ii had a force of xix_i and acted on sections from lil_i to rir_i. As a result of this gust, the height of section number lil_i increased by xix_i, the height of section number li+1l_i+1 decreased by xix_i, the next one increased again by xix_i, and so on until section number rir_i, inclusively. Knowing all the information about all nn gusts of wind, Grigory Georgievich wants to determine the final stabilized height of some m sections that interest him. Help him


Kiruvchi ma'lumotlar:

The first line of the input file contains two natural numbers nn and mm (1n,m1000)(1≤n,m≤1000) — the number of wind gusts and the number of sections whose final height interests Grigory Georgievich. Each of the next nn lines contains the description of the next wind gust — three integers li,ri,xi(1liri109;1xi1000)l_i​,r_i​,x_i​ (1≤l_i​≤r_i​≤10^9; 1≤x_i​≤1000). Each of the next mm lines contains an integer qi(1qi109)q_i ​(1≤q_ i​≤10^9) — the number of the section for which its final height needs to be determined. The section numbers are given in increasing order.


Chiquvchi ma'lumotlar:

Misollar
# input.txt output.txt
1
2 6
1 6 7
3 7 2
1
2
3
6
7
8
7
-7
9
-9
2
0