A factory produces thimbles in bulk. Typically, it can produce up to a thimbles a day. However, some of the machinery is defective, so it can currently only produce b thimbles each day. The factory intends to choose a k-day period to do maintenance and construction; it cannot produce any thimbles during this time, but will be restored to its full production of a thimbles per day after the k days are complete.
Initially, no orders are pending. The factory receives updates of the form di, ai, indicating that ai new orders have been placed for the di-th day. Each order requires a single thimble to be produced on precisely the specified day. The factory may opt to fill as many or as few of the orders in a single batch as it likes.
As orders come in, the factory owner would like to know the maximum number of orders he will be able to fill if he starts repairs on a given day pi. Help the owner answer his questions.
Output
For each query of the second type, print a line containing a single integer − the maximum number of orders that the factory can fill over all
n days.
Note
Consider the first sample.
We produce up to
1 thimble a day currently and will produce up to
2 thimbles a day after repairs. Repairs take
2 days.
For the first question, we are able to fill
1 order on day
1, no orders on days
2 and
3 since we are repairing, no orders on day
4 since no thimbles have been ordered for that day, and
2 orders for day
5 since we are limited to our production capacity, for a total of
3 orders filled.
For the third question, we are able to fill
1 order on day
1,
1 order on day
2, and
2 orders on day
5, for a total of
4 orders.