#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 600005, M = N * 23;
int n, m;
int s[N];
int tr[M][2], root[N], idx;
int max_id[M];
void insert(int i,int k,int p,int q){
if(k < 0){
max_id[q] = i;
return ;
}
int v = s[i] >> k & 1;
if(p) tr[q][v ^ 1] = tr[p][v ^ 1];
tr[q][v] = ++ idx;
insert(i, k - 1, tr[p][v], tr[q][v]);
max_id[q] = max(max_id[tr[q][0]], max_id[tr[q][1]]);
}
int query(int now, int val, int lim){
for(int i = 23;~i;i -- ){
int v = val >> i & 1;
if(max_id[tr[now][v ^ 1]] >= lim) now = tr[now][v ^ 1];
else now = tr[now][v];
}
return val ^ s[max_id[now]];
}
int main(){
scanf("%d%d", &n, &m);
max_id[0] = -1;
// insert 0
root[0] = ++ idx;
insert(0, 23, 0, root[0]);
for (int i = 1; i <= n; i ++ ){
int x;
scanf("%d", &x);
s[i] = s[i - 1] ^ x;
root[i] = ++ idx;
insert(i, 23, root[i - 1], root[i]);
}
char op[2];
int l, r, x;
while (m -- ){
scanf("%s", op);
if (*op == 'A'){
scanf("%d", &x);
n ++ ;
s[n] = s[n - 1] ^ x;
root[n] = ++ idx;
insert(n, 23, root[n - 1], root[n]);
}
else{
scanf("%d%d%d", &l, &r, &x);
printf("%d\n", query(root[r - 1], s[n] ^ x, l - 1));
}
}
return 0;
}