Time limit: 0.5s
Memory limit: 256MB
Input:
Output:
You are given an array of length . You need to process queries. Each query is one of the following two types:
- - What is the value of modulo ?
- - For every in the range [], becomes max()
Input
The first line of input contains the integer , the length of the array.
The second line of the input contains integers, the -th being
The third line of the input contains an integer , the number of queries.
Each of the following lines contains a query of one of two aforementioned types.
Output
The output will contain the answers to queries of type on the order they appear in the input.
Constraints
- For tests worth points, every number in the input is smaller than or equal to , except for
- For tests worth more points, ;
- For tests worth more points, ;
- The scores obtained now may be different compared to the ones from the original contest
Example
stdin
10
5 3 7 8 3 9 10 10 1 2
15
1 7
2 1 5 3 3
1 5
1 4
1 1
2 6 10 2 2
1 6
1 7
1 10
2 1 10 10 10
1 1
1 2
1 10
1 7
1 3
stdout
10
375
192
5
72
98
200
10
10240
999999307
824752476
590490