Dynamic Sum
View as PDFGiven an array of  numbers (initially, each number is set to 
), you need to answer 
 queries of 
 types:
1 i' v': Add  to the 
 number.
2 l' r' x': Query the sum  after undoing the 
 most recent type 
 queries (note: the undo queries are NOT persistent).
Constraints
It is guaranteed that there have been at least  type 
 queries.
Input Specification
The first line will contain  and 
, the number of elements in the array and the number of queries.
The next  lines will contain a query from those listed above.
Note that this problem will be online enforced, meaning that input will be given in an encrypted format. To encrypt the data, the values  in queries will be given as 
, 
, 
, and 
, where 
 denotes the bitwise XOR operation. Note that 
 at any time is defined as the answer to the latest query. If no queries have occurred so far, 
.
Output Specification
Output the answer to each type  query.
Sample Input (Encrypted)
5 6
1 1 5
1 5 9
2 1 5 0
2 15 11 15
1 6 7
2 4 0 5
Sample Input (Unencrypted)
5 6
1 1 5
1 5 9
2 1 5 0
2 1 5 1
1 3 2
2 1 5 0
Sample Output
14
5
16
Comments