#jag2018summerday2i. [jag2018summer_day2_i]ADD DIV MAX RESTORE
[jag2018summer_day2_i]ADD DIV MAX RESTORE
Problem Statement
You are given an integer sequence .
You have to perform queries, each query is one of the following:
ADD QUERY(t=0 l r x)
: for each between and , inclusive, replace with .DIV QUERY(t=1 l r x)
: for each between and , inclusive, replace with , where is the biggest integer that is not greater than .MAX QUERY(t=2 l r x=0)
: print .RESTORE QUERY(t=3 l r x=0)
: for each between and , inclusive, set to the initial value of , that is, the value given in the input.
Constraints
- All input values are integers.
- (when )
Input
Input is given from Standard Input in the following format:
... :
Output
For each MAX QUERY
, print , one per line.
Sample Input 1
5 9
1 2 3 4 5
2 0 4 0
0 0 1 10
2 0 4 0
2 2 2 0
1 0 1 4
2 0 0 0
2 1 1 0
3 0 4 0
2 0 1 0
Sample Output 1
5
12
3
2
3
2
- The array is restored to
Sample Input 2
4 7
0 1 0 1
2 0 3 0
0 0 3 1
1 0 3 2
2 0 3 0
0 0 3 1
1 0 3 2
2 0 3 0
Sample Output 2
1
1
1
Sample Input 3
10 23
13 1 22 8 28 18 23 9 22 27
1 3 4 5
1 8 8 8
0 3 9 5
0 2 6 3
3 0 4 0
1 1 3 7
2 2 2 0
2 3 5 0
0 1 4 2
3 0 9 0
2 0 1 0
0 3 9 8
2 1 9 0
0 8 9 5
1 5 7 7
0 3 5 7
0 7 9 7
3 3 6 0
2 1 6 0
0 1 1 7
1 4 8 10
2 0 9 0
1 5 6 1
Sample Output 3
3
28
13
36
28
47