Monkey and Apple-trees#7488

Monkey and Apple-trees

1 second
122.174 megabytes
Medium

Everyone knows that the yummiest fruit in the world is an apple. Even the monkey Chris knows that. There are many apple-trees in a forest located along the river and numerated consecutively starting from . Sometimes Chris comes to the forest, chooses a group of apple-trees growing consecutively (selected interval) and counts the amount of apple-trees with ripe apples among them. Sometimes apples on a few consecutive apple-trees have ripened before his next arrival.

You have to answer how many apple-trees in the selected interval have ripe apples at each Chris's arrival. At the beginning all the apples are unripe.

Input

In the first line an integer (1 \le m \le 100000) - number of events. The following lines contain description of events - each contains three integers d_i, x_i, y_i (1 \le d_i \le 2, x_i \le y_i). If the d_i = 1, then the event is Chris's arrival, if the d_i = 2 - ripening of all apples in the selected interval of the apple-trees. Other two numbers x_i and y_i, describe the interval for the event.

For calculating the limits of the interval there is an additional number . At the beginning c = 0. An interval for the event is interval from x_i + c to y_i + c inclusively. It's guaranteed that 1 \le x_i + c, y_i + c \le 10^9. If the event is apples ripening then doesn't change. If the event is Chris's arrival, then the previous value of is used to calculate the interval boundaries first, then as the result becomes equal to the amount of apple-trees with ripe apples he has counted.

Output

For each of Chris's arrival output one line with one number in it - the task answer.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Example 3

Loading
Loading