DS = Data structure of Shawn's

时间限制: 1000 ms 内存限制: 65536 kb
总通过人数: 0 总提交人数: 0

Description

Shawn has a magical data structure.

Originally it takes an array of Integers (1-based index ) $A$ whose length is $n$ , and it supports these operations:

Modify a number

M p x means update $A[p] = x$

Segment Division

D L R x which enumerate every number index from L to R inclusive , divide each number by $x$ ( integer division , $3 / 2 = 1$ , $5 / 10 = 0$ )

Segment Sum Query

Q L R you need to output the sum for number from L to R inclusive. Basically $A[L] + A[L + 1] + ... + A[R]$

Input

First line 1 number $n$.

Second line $n$ numbers $A_{i}$.

Third line 1 number $m$.

The rest of $m$ lines , each line contains an operation.

$1 \le n,m \le 10^{5}$

$1 \le A_{i},x \le 10^{9}$

$1 \le L , R , p \le n$

Output

For each query , output a number indicates the answer.

Sample Input

5
1 2 3 4 5
4
Q 1 3
D 1 3 2
M 2 2
Q 1 3

Sample Output

6
3

相关推荐