#include<bits/stdc++.h>
#define ll long long
#define db double
using namespace std;
inline int read()
{
int x = 0; bool op = 0;
char c = getchar();
while(!isdigit(c))op |= (c == '-'), c = getchar() ;
while(isdigit(c))x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
return op ? -x : x;
}
const int N = 300010;
int n, m, tot, ans;
int trie[N * 50][2], exist[N * 50], rt[N];
void update(int p, int q, int x, int dep)
{
if(dep < 0)return ;
int c = (x >> dep) & 1;
trie[q][c ^ 1] = trie[p][c ^ 1]; trie[q][c] = ++tot;
exist[trie[q][c]] = exist[trie[p][c]] + 1;
update(trie[p][c], trie[q][c], x, dep - 1);
return ;
}
void query(int p, int q, int x, int dep)
{
if(dep < 0)return ;
int c = (x >> dep) & 1;
if(exist[trie[q][c ^ 1]] > exist[trie[p][c ^ 1]])
ans += (1 << dep), query(trie[p][c ^ 1], trie[q][c ^ 1], x, dep - 1);
else query(trie[p][c], trie[q][c], x, dep - 1);
return ;
}
int main()
{
n = read(); m = read();
int sum = 0, len = n; rt[0] = 0;
for(int i = 1; i <= n; i++)
{
rt[i] = ++tot;
update(rt[i - 1], rt[i], sum, 31);
int x = read(); sum ^= x;
}
for(int i = 1; i <= m; i++)
{
char op; cin >> op;
if(op == 'A')
{
int x = read(); len++;
rt[len] = ++tot;
update(rt[len - 1], rt[len], sum, 31);
sum ^= x;
}
else
{
int l = read(), r = read(), x = read();
ans = 0; query(rt[l - 1], rt[r], sum ^ x, 31);
printf("%d\n", ans);
}
}
return 0;
}