const maxn=;
len=;
var x,y,z,n,m,tot,lx,i:longint;
sum:array[..maxn] of longint;
rt:array[..maxn] of longint;
time,l,r:array[..maxn*len] of longint;
ch:char;
procedure insert(x:longint);inline;
var p,i:longint;
begin
rt[lx]:=tot+; p:=rt[lx-];
for i:=len downto do
begin
inc(tot); l[tot]:=l[p]; r[tot]:=r[p]; time[tot]:=time[p]+;
if (x and (<<(i-))) > then
begin
p:=r[p];
r[tot]:=tot+;
end else
begin
p:=l[p];
l[tot]:=tot+;
end;
end;
inc(tot); l[tot]:=l[p]; r[tot]:=r[p]; time[tot]:=time[p]+;
end;
function query(a,b,x:longint):longint;inline;
var ans,i:longint;
begin
ans:=;
for i:=len downto do
begin
if (x and (<<(i-))) > then
begin
if time[l[b]]>time[l[a]] then
begin
a:=l[a]; b:=l[b];
ans:=ans+<<(i-);
end
else
begin
a:=r[a]; b:=r[b];
end
end else
begin
if time[r[b]]>time[r[a]] then
begin
a:=r[a]; b:=r[b];
ans:=ans+<<(i-);
end
else
begin
a:=l[a]; b:=l[b];
end
end;
end;
exit(ans);
end;
begin
readln(n,m);
sum[]:=; lx:=;
insert();
for i:= to n do
begin
read(x);
inc(lx);
sum[lx]:=x xor sum[lx-];
insert(sum[lx]);
end;
readln;
for i:= to m do
begin
read(ch);
if ch='A' then
begin
readln(x);
inc(lx);
sum[lx]:=x xor sum[lx-];
insert(sum[lx]);
end else
begin
readln(x,y,z);
writeln(query(rt[x-],rt[y],z xor sum[lx]));
end;
end;
end.