As the cross country running competition date approaches, Jonathan is practicing harder than ever for his race.
Near his house, there is a long track that can be represented as a chain of continuous segments of road, numbered from to . Each segment of road is initially metres long - however, as the City of Toronto is notorious for its frequent constructions, the length of specific roads may change over the next few days.
When Jonathan decides to practice, he will choose a starting position at the beginning of one of these roads and will continue running forward as far as can under the limit of his lung capacity, , where is in meters. That is, he will run continuous meters either until adding the next segment of road would exceed or if he finishes the th road. Additionally, after each practice, his lung capacity will increase by meters.
Besides just running practice, though, intense cross country also calls for one to own a ridiculous collection of shoes. It is rumored that depending on the shoe that one is wearing, the runner's lung capacity may even increase! Jonathan has a collection of shoes, each of which provides him with an extra running capacity. Note that this is not a permanent increase to his lung capacity - it is merely an add-on. By default, Jonathan will wear his st pair of shoes.
Over the course of the next days, one of three events can occur: A segment of road's length is updated, Jonathan goes for a run, or Jonathan switches his shoes.
More specifically, there will be three types of queries:
1 x y
The th segment of road has its length updated to meters.2 L
Jonathan goes for a run starting from the th segment of road.3 x
Jonathan switches his current pair of shoes for the th pair.
For every type 2
query, print out the longest length in meters that he can run.
Constraints
For every type 3
query, it is guaranteed that the new pair of shoes Jonathan switches to is different from his previous pair.
Input Specification
The first line will contain , , , , , space-separated.
The next line will contain integers , the length of each road.
The next line will contain integers , the boost of each pair of shoes.
The next lines will contain a query of the form defined above.
Output Specification
For every type 2
query, print out the longest length in meters that he can run on its own line.
Sample Input 1
5 10 15 3 3
8 5 3 4 10
2 6 5
3 2
2 2
3 3
2 1
2 2
1 3 10
2 3
3 1
1 4 3
3 2
Sample Output 1
12
20
22
24
Sample 1 Explanation
Initially, Jonathan's running capability is . After switching his shoes to the nd pair, his running capability is . For his first practice, he can run up to meters. Note that if he tries running the next segment, the total length will be meters, and since , he can't run that length.
Comments