Joe is an economical man and he has found a new scheme to save some money! Joe wants to save money on his water bill, so he decides to collect rainwater. Joe has a row of
: Rainfall arrives, and liters of water falls directly into each container from position to inclusive. : Joe changes the maximum capacity of bucket to . If the volume decreases, any resulting overflow passes on to bucket as usual. : Joe wishes to know the current volume of water being held in container .
Constraints
Subtask 1 [10%]
Subtask 2 [10%]
All queries of type
Subtask 3 [30%]
For all queries of type
Subtask 4 [50%]
No additional constraints.
Input Specification
The first line will contain
The second line will contain
The next
Output Specification
Output the answer to each type
Sample Input
5 5
4 5 2 9 3
1 1 2 3
2 1 1
1 2 5 2
3 4
3 5
Sample Output
4
2
Comments