Riolku has
Each friend has one figurine that they consider "prized", and would never willingly give away, whereas they have another that they could trade, which we will call their "trade" figurine.
Being figurine connoisseurs, Riolku and his friends know that each figurine has a specific value. Initially, the prized figurines have values
Sometimes, Riolku gets greedy and steals some of his friend's prized figurines, replacing them with look-alikes all with value
Occasionally he wonders who has the most valuable pair of figurines. The value of a pair is the value of their prized figurine plus the value of their trade figurine.
Riolku will only do 3 actions. The action specifics are below:
- Riolku steals some of his friend's prized figurines. For each friend with label between
and , he will replace their prized figurine with one of value . Formally, for all such that , set . - Riolku feels remorse and offers his friends some new figurines. For each friend with label between
and , he will offer a figurine of value with which to replace their trade figurine. Formally, for all such that , set . - Riolku wonders who has the best figurine pair. He wants to know the value of the best figurine pair for all friends with labels between
and . Formally, find .
Riolku will perform
Constraints
Input Specification
The first line contains two space-separated integers,
The next line contains
The next line contains
Then
1 l r k
2 l r k
3 l r
The first integer indicates the operation to be performed, corresponding with the task description.
Output Specification
For each operation of type
Sample Input
4 6
1 2 3 4
6 2 9 5
3 1 4
1 1 3 2
3 1 2
2 1 4 7
3 1 4
3 2 3
Sample Output
12
8
11
11
Comments