Problem10275--CF EDU - Segment Tree P1 - Step 3 - E. Addition to Segment

10275: CF EDU - Segment Tree P1 - Step 3 - E. Addition to Segment

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

There is an array of $n$ elements, initially filled with zeros. You need to write a data structure that processes two types of queries:

  • add to the segment from $l$ to $r−1$ the number $v$,
  • find the current value of element $i$.

You may have heard that such requests can be made using the tree of segments with mass change operations (we will talk about it in the next lesson), but this problem can be solved using a regular segment tree.

Input

The first line contains two numbers $n,m\ (1≤n,m≤100,000)$, the size of the array and the number of operations. 

The following lines contain the description of the operations. The description of each operation is as follows:

  • $\text{1 l r v}$: add the value $v$ to the segment from $l$ to $r−1\ (0≤l<r≤n,\ 0≤v≤10^9)$.
  • $\text{2 i}$: find the value of the element with index $i\ (0≤i<n)$.

Output

For each operation of the second type, print the corresponding value.

Sample 1 Input

5 5
1 0 3 3
2 1
1 2 4 4
2 3
2 4

Sample 1 Output

3
4
0

HINT

CF EDU.

Source/Category