#include using namespace std; #define rep(i, n) for(int i = 0; i < (int)n; ++i) #define FOR(i, a, b) for(int i = a; i < (int)b; ++i) #define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i) using ll = long long; using ld = long double; const ll INF = 1e18; const int Inf = 1e9; const double EPS = 1e-9; const int MOD = 1e9 + 7; template class SegmentTree { public: int n; T e; vector node; function operation; function process; SegmentTree() {} SegmentTree(int n_, T e_, function operation_, function process_) : e(e_), operation(operation_), process(process_) { n = 1; while (n < n_) n <<= 1; node.assign(2 * n, e); } void build() { for (int i = n - 1; i > 0; --i) { node[i] = operation(node[i * 2 + 0], node[i * 2 + 1]); } } void set(int idx, T v) { node[idx + n] = process(node[idx + n], v); } void update(int idx, T v) { idx += n; node[idx] = process(node[idx], v); while (idx >>= 1) { node[idx] = operation(node[idx * 2 + 0], node[idx * 2 + 1]); } } T query(int a, int b) { return query(a, b + 1, 1, 0, n); } T query(int a, int b, int k, int l, int r) { if (a >= r || b <= l) return e; if (a <= l && b >= r) return node[k]; T c = query(a, b, 2 * k + 0, l, (l + r) / 2); T d = query(a, b, 2 * k + 1, (l + r) / 2, r); return operation(c, d); } T operator[](int idx) { return node[idx + n]; } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(0); int n, q; cin >> n >> q; SegmentTree seg = SegmentTree(n, 0, [](int a, int b) { return a ^ b; }, [](int a, int b) { return b; }); rep (i, n) { int a; cin >> a; seg.set(i, a); } seg.build(); rep (i, q) { int l, r; cin >> l >> r; cout << seg.query(l - 1, r - 1) << endl; } return 0; }