Spring is coming and in order to please the Buntopian kids, you decided to buy for them many balls of different types, namely types of balls.
For the first game, you asked them to arrange all the balls in such a way that among all the possible arrangements of balls, the sum of subarray beauties is as small as possible.
For a given arrangement, the sum of subarray beauties is computed in the following way:
We compute all the maximal subarrays consisting of balls having the same color and then for each of them, we add up to the answer , where is the length of the subarray.
For example, if we have the array , the sum of beauties will be .
Since Buntopian kids are some of the best kids at math from the entire universe, in order to challenge them, now you ask them to compute some of these values during the next days, while considering potential changes in the number of balls from the gift as well. However, since the values are too big, they are only asking for the remainder of the answer when dividing by .
Can you repeat Buntopian kids' achievement?
Input
The first line of the input contains and , the number of types of balls and the number of queries .
The next line of the input contains the numbers, representing the initial quantities of each type of ball .
The next lines contain the queries, which are of two types:
1 a b
: The number of balls of type becomes ().
2 x y
: Buntopian kids now want to know the answer for the problem, if we only consider types of balls in range .
For tests worth points, .
Output
The output will contain one line for each query of type , representing the answer asked by Buntopian kids modulo .
Example
stdin
7 6
4 2 18 5 7 9 3
2 2 4
1 5 19
2 1 7
2 3 6
1 2 106
2 1 7
stdout
54
120
102
328