Dima and the Time Machine#2938

Dima and the Time Machine

2 seconds
256 megabytes
Very easy (≈850)

Mom gave Dima a time machine. However, this machine only works with a built-in array of length . The machine can revert the array to its state at any moment in time. This array is not ordinary—it is special. Dima can choose two numbers and (1 \leq i \leq n, -1000 \leq d \leq 1000), and magically add to the element at index of the array. As Dima plays with his array, his mom occasionally asks him what is the sum of the numbers in the array between indices and . Dima easily answers these questions, but can you?

Input

The first line contains two integers and (1 \leq n, q \leq 10^5) — the number of elements in the array and the total number of operations and queries, respectively. The next line contains integers a_1, a_2, \dots, a_n (-1000 \leq a_i \leq 1000) — the initial state of the array. The following lines describe the operations and queries. Each line begins with a character: , , or . If the line starts with , this is a time machine operation. It is followed by a number (1 \leq i) — the operation or query number to which the array should revert. is always less than or equal to the current operation number. If the line starts with , it signifies an addition operation, followed by and , which are within the constraints described above. If the line starts with — it is a query, followed by and (1 \leq f, t \leq n).

Output

For each query, output the sum of the numbers in the array from indices to (inclusive), one result per line.

Examples

Example 1

Loading
Loading