#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+10;
int n,m,num,cnt;
int trie[N*24][2],val[N*24];
int s[N],root[N];
inline int read()
{
int x = 0, f = 1; char c; c = getchar();
while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=x*10+c-48;c=getchar();}
return x*f;
}
void insert(int pre,int &cur,int len,int i)
{
if(cur==0) cur=++cnt;
val[cur] = i;
if(len<0) return;
bool c = (s[i]>>len)&1;
trie[cur][c^1] = trie[pre][c^1];
insert(trie[pre][c],trie[cur][c],len-1,i);
}
int find(int l,int cur,int len,int v)
{
if(len<0)return s[val[cur]]^v;
int c=(v>>len)&1;
if(val[trie[cur][c^1]]>=l) return find(l,trie[cur][c^1],len-1,v);
return find(l,trie[cur][c],len-1,v);
}
int main()
{
n = read(); m = read();
val[0]=-1;
insert(0,root[0],23,0);
for(int i = 1,v; i <= n; ++i)
{
v = read(); s[i]=s[i-1]^v;
insert(root[i-1],root[i],23,i);
}
num = n;
for(int i = 1; i <= m; ++i)
{
char opt[2]; scanf("%s",opt);
if(opt[0]=='A')
{
int x = read();s[++num]=s[num-1]^x;
insert(root[num-1],root[num],23,num);
}
else
{
int l = read(), r = read(), x = read();
printf("%d\n",find(l-1,root[r-1],23,x^s[num]));
}
}
}