7383 - Traps on Ground   

Description

One day, you want to practice jogging on the playground. But some items usually run into the track where you are jogging. For example, footballs, baseballs, and other people are the majority of the items. You want to know the situation of the track every time. To simplify this problem, the track looks like an array of n grids. There are q events that happen on the track. Looks like
1. “c x y” means “counting the number of items on the interval [x, y]”
2. “p x y” means “x items (run into) / (are picked up) on the grid y”
For every type-1 event, please out the number of items.

Input

Each test case starts with a line containing two integers n (1 ≤ n ≤ 105) and q (1 ≤ q ≤ 2 ∗ 105) indicating the length of the track and the number of events.
Following this are q lines, each containing one character c and two integers x, y. The first character c specifies the type of the event. For the type-1 event, x and y mean the interval you want to check. (1 ≤ x ≤ y ≤ n) For the type-2 event, x means the number of the items running into the track (when x > 0) or the number of the items been taken out (when x < 0).

Output

For every type-1 event, output the number of the items on the interval [x, y].

Sample Input  Download

Sample Output  Download

Tags




Discuss