Masala F
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 to 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 had a force of and acted on sections from to . As a result of this gust, the height of section number increased by , the height of section number decreased by , the next one increased again by , and so on until section number , inclusively. Knowing all the information about all gusts of wind, Grigory Georgievich wants to determine the final stabilized height of some m sections that interest him. Help him
The first line of the input file contains two natural numbers and — the number of wind gusts and the number of sections whose final height interests Grigory Georgievich. Each of the next lines contains the description of the next wind gust — three integers . Each of the next lines contains an integer — the number of the section for which its final height needs to be determined. The section numbers are given in increasing order.
# | 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 |