#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string.h>
using namespace std;
struct TrieNode {
int next[2];
int max_word_idx;
TrieNode() {
next[1] = -1;
next[0] = -1;
max_word_idx = -1;
}
};
int __global_idx = 0;
TrieNode __node_buf[600002*25];
int __root_entry[600002];
class PersistentTrie {
private:
int* root_entry;
int __length;
public:
PersistentTrie() {
__length = 0;
root_entry = __root_entry;
}
void append(const char* s) {
root_entry[__length++] = __global_idx++;
int len = __length;
int cur = root_entry[len-1], prev_cur = -1;
if (len >= 2) {
prev_cur = root_entry[len-2];
}
__node_buf[cur].max_word_idx = max(__node_buf[cur].max_word_idx, len-1);
int ch = 0;
for (int i = 0; i < 25; i++) {
ch = s[i];
if (prev_cur != -1) {
__node_buf[cur].next[0] = __node_buf[prev_cur].next[0];
__node_buf[cur].next[1] = __node_buf[prev_cur].next[1];
}
__node_buf[cur].next[ch] = __global_idx++;
cur = __node_buf[cur].next[ch];
if (prev_cur != -1) {
prev_cur = __node_buf[prev_cur].next[ch];
}
__node_buf[cur].max_word_idx = max(__node_buf[cur].max_word_idx, len-1);
}
}
int get_root(int version) {
return root_entry[version];
}
};
char str_buf[26];
void val2str(int val, char* buf) {
int base = 1 << 24;
int i = 0;
while (base) {
buf[i] = (val & base) ? 1 : 0;
i += 1;
base >>= 1;
}
}
int find_best_val(int root, int val, int start) {
int cur = root;
int ans = 0;
for (int cur_bit = 24; cur_bit >= 0; cur_bit--) {
if ((val & (1 << cur_bit)) == 0) {
if (__node_buf[cur].next[1] != -1 && __node_buf[__node_buf[cur].next[1]].max_word_idx >= start) {
cur = __node_buf[cur].next[1];
ans |= (1 << cur_bit);
} else {
cur = __node_buf[cur].next[0];
}
} else {
if (__node_buf[cur].next[0] != -1 && __node_buf[__node_buf[cur].next[0]].max_word_idx >= start) {
cur = __node_buf[cur].next[0];
} else {
cur = __node_buf[cur].next[1];
ans |= (1 << cur_bit);
}
}
}
return ans;
}
int main(void) {
//freopen("/Users/grh/Programming/CLionProjects/Test/data.txt", "r", stdin);
int n, m, val;
scanf("%d %d", &n, &m);
PersistentTrie trie;
val2str(0, str_buf);
trie.append(str_buf);
int S = 0;
for (int i = 0; i < n; i++) {
scanf("%d", &val);
S ^= val;
val2str(S, str_buf);
trie.append(str_buf);
}
char cmd[2];
int start, end, x;
for (int i = 0; i < n; i++) {
scanf("%s", cmd);
if (cmd[0] == 'A') {
scanf("%d", &val);
S ^= val;
val2str(S, str_buf);
trie.append(str_buf);
} else {
scanf("%d %d %d", &start, &end, &x);
start--;
end --;
int select_val = find_best_val(trie.get_root(end), S^x, start);
printf("%d\n", select_val ^ S ^ x);
}
}
}