#C11627. Sequence Transformation

    ID: 40964 Type: Default 1000ms 256MiB

Sequence Transformation

Sequence Transformation

You are given a sequence of n integers and m transformation rules. Each transformation rule is represented as a triplet \( (l, r, k) \), which means that for every index \( i \) satisfying \( l \leq i \leq r \) the element at position \( i \) should be increased by \( k \). The positions are 1-indexed.

Your task is to apply all the given transformation rules in the order they are provided and output the final sequence.

Note: The transformation for a rule is defined as:

[ \text{For each } i \text{ with } l \leq i \leq r, \quad A_i := A_i + k ]

Read input from stdin and write the output to stdout as described below.

inputFormat

The first line contains two integers \( n \) and \( m \) separated by space, where \( n \) is the length of the sequence and \( m \) is the number of transformation rules.

The second line contains \( n \) integers denoting the initial sequence.

Each of the following \( m \) lines contains three integers \( l \), \( r \), and \( k \), representing a transformation rule.

Constraints: All inputs are valid and follow the above format.

outputFormat

Output a single line containing the final transformed sequence. The elements should be printed in order and separated by a single space.

## sample
5 3
1 2 3 4 5
1 3 2
2 4 -1
3 5 3
3 3 7 6 8