#K78207. Taco's Price Update Challenge

    ID: 35035 Type: Default 1000ms 256MiB

Taco's Price Update Challenge

Taco's Price Update Challenge

You are given the initial prices of N products and a series of events that update the prices over a range of products. For each event, you are provided with three integers L, R, and X, which indicates that X should be added to each product's price in the range L to R (inclusive).

Mathematically, if the initial price of the i-th product is \(p_i\), and the events are applied, the final price \(p_i^\prime\) is computed as:

\[ p_i^\prime = p_i + \sum_{\text{event } (L, R, X) \text{ with } L \le i \le R} X \]

After applying all events, you will be given a set of queries. Each query is an index, and you must output the final price for that product.

Your task is to implement a program that reads the input from standard input (stdin) and prints the output to standard output (stdout).

inputFormat

The input is given in the following format:

N Q
p1 p2 ... pN
M
L1 R1 X1
L2 R2 X2
... 
LM RM XM
q1 q2 ... qQ

Where the first line contains two integers: N (number of products) and Q (number of queries). The second line contains N integers representing the initial prices. The third line contains an integer M which represents the number of events. The following M lines each contain three integers L, R, and X. The last line contains Q query indices. Note that product indices are 1-indexed.

outputFormat

Output a single line with Q integers separated by a single space. Each integer represents the final price of the queried product after the events are applied.

## sample
5 2
100 200 300 400 500
3
1 3 50
2 5 -100
3 3 75
1 4
150 300

</p>