#P1572F. Stations
Stations
No submission language available for this problem.
Description
There are cities in a row numbered from to .
The cities will be building broadcasting stations. The station in the -th city has height and range . It can broadcast information to city if the following constraints are met:
- , and
- for each such that , the following condition holds: .
At the beginning, for every city , and .
Then events will take place. During -th event one of the following will happen:
- City will rebuild its station so that its height will be strictly highest among all stations and will be set to .
- Let be the number of stations that can broadcast information to city . Print the sum of over all satisfying .
Your task is to react to all events and print answers to all queries.
The first line contains two integers and () — number of cities and number of events.
Then lines follow. The -th line begins with an integer ( or ).
If a station will be rebuilt. Then two integers and () follow — the city in which the station is rebuilt and its new broadcasting range.
If you are given a query. Then two integers and () follow — the range of cities in the query.
For each query, print in a single line the sum of over the given interval.
Input
The first line contains two integers and () — number of cities and number of events.
Then lines follow. The -th line begins with an integer ( or ).
If a station will be rebuilt. Then two integers and () follow — the city in which the station is rebuilt and its new broadcasting range.
If you are given a query. Then two integers and () follow — the range of cities in the query.
Output
For each query, print in a single line the sum of over the given interval.
Samples
Note
In the first test case, only station reaches city before and after it is rebuilt.
In the second test case, after each rebuild, the array looks as follows:
- ;
- ;
- ;
- ;
- .