#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N,Q; cin >> N >> Q; vector A(N); for(auto &a : A) cin >> a; vector> Q1,Q2; auto memo = A; for(int i=0; i> t; if(t == 1){ int pos,x; cin >> pos >> x; pos--; Q1.push_back({pos,A.at(pos),x}); A.at(pos) = x; } else{ int r; cin >> r; Q2.push_back({Q1.size(),r,-1}); } } A = memo; int B = 150; int n = Q1.size()+1; vector>> Query((n+B-1)/B); for(int i=0; i answer(Q2.size()); for(int i=0; i<(n+B-1)/B; i++){ set> S; priority_queue,vector>,greater<>> Q; int l = i*B,r = 0; sort(Query.at(i).begin(),Query.at(i).end()); for(auto [R,L,qpos] : Query.at(i)){ while(r < R){ int a = A.at(r); auto itr = S.lower_bound({a,r}); if(itr != S.end()){ auto [a2,p] = *itr; Q.push({a^a2,p,r}); } if(itr != S.begin()){ itr--; auto [a2,p] = *itr; Q.push({a^a2,p,r}); itr++; } S.insert({a,r}); r++; } while(l < L){ auto [pos,a,b] = Q1.at(l++); if(pos < r) S.erase({a,pos}); A.at(pos) = b; if(pos < r){ auto itr = S.lower_bound({b,pos}); if(itr != S.end()){ auto [a2,p] = *itr; Q.push({b^a2,p,pos}); } if(itr != S.begin()){ itr--; auto [a2,p] = *itr; Q.push({b^a2,p,pos}); itr++; } S.insert({b,pos}); } } while(l > L){ auto [pos,a,b] = Q1.at(--l); if(pos < r) S.erase({b,pos}); A.at(pos) = a; if(pos < r){ auto itr = S.lower_bound({a,pos}); if(itr != S.end()){ auto [a2,p] = *itr; Q.push({a^a2,p,pos}); } if(itr != S.begin()){ itr--; auto [a2,p] = *itr; Q.push({a^a2,p,pos}); itr++; } S.insert({a,pos}); } } while(Q.size()){ auto [v,p,q] = Q.top(); if(p >= r || q >= r || (A.at(p)^A.at(q)) != v){Q.pop(); continue;} answer.at(qpos) = v; break; } } while(l < min(n-1,(i+1)*B)){ auto [pos,a,b] = Q1.at(l++); A.at(pos) = b; } while(l > min(n-1,(i+1)*B)){ auto [pos,a,b] = Q1.at(--l); A.at(pos) = a; } } for(auto a : answer) cout << a << "\n"; }