import java.io.*;
class Main{
static BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
static BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
static Node[] tr;
static long[] w;
static int n, m;
public static void main(String[] args) throws Exception{
String[] ss = read.readLine().split(" ");
n = Integer.valueOf(ss[0]); m = Integer.valueOf(ss[1]);
w = new long[n + 1]; tr = new Node[n * 4];
ss = read.readLine().split(" ");
for(int i = 1; i <= n; i++){
w[i] = Long.valueOf(ss[i - 1]);
}
build(1, 1, n);
while(m -- > 0){
ss = read.readLine().split(" ");
int a = Integer.valueOf(ss[1]), b = Integer.valueOf(ss[2]);
switch(ss[0]){
case "Q":
long left = query(1, 1, a).sum, right = query(1, a + 1, b).gcd;
log.write(Math.abs(gcd(left, right)) + "\n");
break;
case "C":
long c = Long.valueOf(ss[3]);
modify(1, a, c); if(b + 1 <= n) modify(1, b + 1, -c);
break;
}
}
log.flush();
}
public static void build(int u, int l, int r){
if(l == r){
tr[u] = new Node(l, r, w[l] - w[l - 1], w[l] - w[l - 1]);
}else{
tr[u] = new Node(l, r);
int mid = tr[u].l + tr[u].r >> 1;
build(u << 1, l, mid); build(u << 1 | 1, mid + 1, r);
pushUp(u);
}
}
public static Node query(int u, int l, int r){
if(tr[u].l >= l && tr[u].r <= r) return tr[u];
else{
long mid = tr[u].l + tr[u].r >> 1;
if(r <= mid) return query(u << 1, l, r);
else if(l > mid) return query(u << 1 | 1, l, r);
else{
Node left = query(u << 1, l, r);
Node right = query(u << 1 | 1, l, r);
Node res = new Node(l, r);
pushUp(res, left, right);
return res;
}
}
}
public static void modify(int u, int x, long c){
if(tr[u].l == x && tr[u].r == x){
tr[u].sum += c;
tr[u].gcd += c;
}else{
long mid = tr[u].l + tr[u].r >> 1;
if(x <= mid) modify(u << 1, x, c);
else modify(u << 1 | 1, x, c);
pushUp(u);
}
}
public static void pushUp(int u){
pushUp(tr[u], tr[u << 1], tr[u << 1 | 1]);
}
public static void pushUp(Node u, Node l, Node r){
u.sum = l.sum + r.sum;
u.gcd = gcd(l.gcd, r.gcd);
}
public static long gcd(long a, long b){
return b == 0 ? a : gcd(b, a % b);
}
static class Node{
int l, r;
long sum;
long gcd;
Node(int l, int r){
this.l = l; this.r = r;
}
Node(int l, int r, long sum, long gcd){
this.l = l; this.r = r; this.sum = sum; this.gcd = gcd;
}
}
}
能问一下用Scanner是会TLE吗,我就是用了Scanner,感觉其他思路都差不多,就TLE呀。