You have an array of elements, indexed from to . There are operations you need to perform on it.
Each operation is one of the following:
C x v
change the -th element of the array to .M l r
output the minimum of all elements between indicies and , inclusive.G l r
output the greatest common divisor of all elements between indicies and , inclusive.Q l r
let be the result ofG l r
right now. Output the number of elements between indicies and , inclusive, equal to .
Constraints
At any time, every element in the array is between and , inclusive.
Input Specification
The first line contains and .
The second line contains integer,s the original array.
The next lines each contain an operation as described above.
Output Specification
For each M
, G
, and Q
query, output the answer on a new line.
Sample Input 1
5 5
1 1 4 2 8
C 2 16
M 2 4
G 2 3
C 2 1
Q 1 5
Sample Output 1
2
4
2
Sample Input 2
5 2
1 1 2 2 2
Q 1 4
Q 3 5
Sample Output 2
2
3
Comments