#include using namespace std; #define all(...) std::begin(__VA_ARGS__), std::end(__VA_ARGS__) #define rall(...) std::rbegin(__VA_ARGS__), std::rend(__VA_ARGS__) #define OVERLOAD_REP(_1, _2, _3, _4, name, ...) name #define REP1(n) for(ll i=0;i<(n);i++) #define REP2(i, n) for (ll i=0;i<(n);i++) #define REP3(i, a, n) for (ll i=a;i<(n);i++) #define REP4(i, a, b, n) for(ll i=a;i<(n);i+=b) #define rep(...) OVERLOAD_REP(__VA_ARGS__, REP4, REP3, REP2, REP1)(__VA_ARGS__) #define OVERLOAD_RREP(_1, _2, _3, _4, name, ...) name #define RREP1(n) for(ll i=(n)-1;i>=0;i--) #define RREP2(i, n) for(ll i=(n)-1;i>=0;i--) #define RREP3(i, a, n) for(ll i=(n)-1;i>=(a);i--) #define RREP4(i, a, b, n) for(ll i=(n)-1;i>=(a);i-=(b)) #define rrep(...) OVERLOAD_RREP(__VA_ARGS__, RREP4, RREP3, RREP2, RREP1)(__VA_ARGS__) #define uniq(a) sort(all(a));a.erase(unique(all(a)),end(a)) #define len(n) (long long)(n).size() using ll = int; using ld = long double; using ull = unsigned long long; using vi = vector; using vvi = vector; using vvvi = vector; using vll = vector; using vvll = vector; using vvvll = vector; using vs = vector; using vvs = vector; using vvvs = vector; using vld = vector; using vvld = vector; using vvvld = vector; using vc = vector; using vvc = vector; using vvvc = vector; using pll = pair; using vpll = vector; using vvpll = vector; ll intpow(ll a,ll b){ ll ans = 1; while (b){ if (b & 1){ ans *= a; } a *= a; b /= 2; } return ans; } ll modpow(ll a,ll b,ll c){ ll ans = 1; while (b){ if (b & 1){ ans *= a; ans %= c; } a *= a; a %= c; b /= 2; } return ans; } template inline T floor(T a, T b) { T q = a / b; T r = a % b; if (r != 0 && ((r < 0) != (b < 0))) q--; return q; } template inline T ceil(T a, T b) { T q = a / b; T r = a % b; if (r != 0 && ((r < 0) == (b < 0))) q++; return q; } template inline T bmod(T a, T b) { T r = a % b; if (r < 0) r += std::abs(b); return r; } template vector>> group_by_first(vector> vec) { sort(vec.begin(), vec.end(), [](auto& a, auto& b) { if (a.first != b.first) return a.first < b.first; return a.second < b.second; }); vector>> res; for (auto& p : vec) { if (res.empty() || res.back().back().first != p.first) { res.push_back({}); } res.back().push_back(p); } return res; } template void input(T&... a){ (cin >> ... >> a); } #define INT(...) int __VA_ARGS__; input(__VA_ARGS__) #define LL(...) ll __VA_ARGS__; input(__VA_ARGS__) #define ULL(...) ull __VA_ARGS__; input(__VA_ARGS__) #define LD(...) ld __VA_ARGS__; input(__VA_ARGS__) #define STR(...) string __VA_ARGS__; input(__VA_ARGS__) #define CHA(...) char __VA_ARGS__; input(__VA_ARGS__) #define VLL(name,length) vll name(length);rep(i,length){cin >> name[i];} #define VVLL(name,h,w) vvll name(h,vll(w));rep(i,h)rep(j,w){cin >> name[i][j];} #define VVVLL(name,a,b,c) vvvll name(a,vvll(b,vll(c)));rep(i,a)rep(j,b)rep(k,c){cin >> name[i][j][k];} #define VI(name,length) vi name(length);rep(i,length){cin >> name[i];} #define VVI(name,h,w) vvi name(h,vi(w));rep(i,h)rep(j,w){cin >> name[i][j];} #define VVVI(name,a,b,c) vvvi name(a,vvll(b,vi(c)));rep(i,a)rep(j,b)rep(k,c){cin >> name[i][j][k];} #define VLD(name,length) vld name(length);rep(i,length){cin >> name[i];} #define VVLD(name,h,w) vvld name(h,vld(w));rep(i,h)rep(j,w){cin >> name[i][j];} #define VVVLD(name,a,b,c) vvvld name(a,vvld(b,vld(c)));rep(i,a)rep(j,b)rep(k,c){cin >> name[i][j][k];} #define VC(name,length) vc name(length);rep(i,length){cin >> name[i];} #define VVC(name,h,w) vvc name(h,vc(w));rep(i,h)rep(j,w){cin >> name[i][j];} #define VVVC(name,a,b,c) vvvc name(a,vvc(b,vc(c)));rep(i,a)rep(j,b)rep(k,c){cin >> name[i][j][k];} #define VS(name,length) vs name(length);rep(i,length){cin >> name[i];} #define VVS(name,h,w) vvs name(h,vs(w));rep(i,h)rep(j,w){cin >> name[i][j];} #define VVVS(name,a,b,c) vvvs name(a,vvs(b,vs(c)));rep(i,a)rep(j,b)rep(k,c){cin >> name[i][j][k];} #define PLL(name) pll name;cin>>name.first>>name.second; #define VPLL(name,length) vpll name(length);rep(i,length){cin>>name[i].first>>name[i].second;} void print(){cout << "\n";} template std::ostream& operator<<(std::ostream& os, const std::pair& p) { os << "(" << p.first << ", " << p.second << ")"; return os; } template std::ostream& operator<<(std::ostream& os, const std::vector& vec) { os << "["; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i + 1 < vec.size()) os << ", "; } os << "]"; return os; } template std::ostream& operator<<(std::ostream& os, const std::vector>& a) { os << "["; for (size_t j = 0; j < a.size(); ++j) { os << "(" << a[j].first << ", " << a[j].second << ")"; if (j + 1 < a.size()) os << ", "; } os << "]"; return os; } template std::ostream& operator<<(std::ostream& os, const std::vector>>& mat) { os << "["; for (size_t i = 0; i < mat.size(); ++i) { os << "["; for (size_t j = 0; j < mat[i].size(); ++j) { os << "(" << mat[i][j].first << ", " << mat[i][j].second << ")"; if (j + 1 < mat[i].size()) os << ", "; } os << "]"; if (i + 1 < mat.size()) os << ", "; } os << "]"; return os; } template std::ostream& operator<<(std::ostream& os, const std::multiset& s) { os << "{"; bool first = true; for (const auto& x : s) { if (!first) os << ", "; os << x; first = false; } os << "}"; return os; } template std::ostream& operator<<(std::ostream& os, const std::map& m) { os << "{"; bool first = true; for (const auto& [key, val] : m) { if (!first) os << ", "; os << key << ": " << val; first = false; } os << "}"; return os; } template void print(const T& a, const Ts&... b){cout << a;(cout << ... << (cout << ' ', b));cout << '\n';} #ifdef LOCAL void debug() { std::cerr << "\n"; } template void debug(const T& a, const Ts&... b) { std::cerr << a; (std::cerr << ... << (std::cerr << ' ', b)); std::cerr << '\n'; } void debug_space() {} template void debug_space(const T& a, const Ts&... b) { std::cerr << a; (std::cerr << ... << (std::cerr << ' ', b)); } #else #define debug(...) (void)0 #endif template T sum(const std::vector& v) { return std::accumulate(v.begin(), v.end(), T(0)); } template auto le(const Set &s, const typename Set::value_type &x, const typename Set::value_type &ngval = typename Set::value_type(-1)) { auto it = s.upper_bound(x); if (it == s.begin()) return ngval; return *prev(it); } template auto lt(const Set &s, const typename Set::value_type &x, const typename Set::value_type &ngval = typename Set::value_type(-1)) { auto it = s.lower_bound(x); if (it == s.begin()) return ngval; return *prev(it); } template auto ge(const Set &s, const typename Set::value_type &x, const typename Set::value_type &ngval = typename Set::value_type(-1)) { auto it = s.lower_bound(x); if (it == s.end()) return ngval; return *it; } template auto gt(const Set &s, const typename Set::value_type &x, const typename Set::value_type &ngval = typename Set::value_type(-1)) { auto it = s.upper_bound(x); if (it == s.end()) return ngval; return *it; } template bool chmin(T& a, const T& b){ if(a > b){ a = b; return 1; } return 0; } template bool chmax(T& a, const T& b){ if(a < b){ a = b; return 1; } return 0; } template bool chmin(T& a, const U& b){ if(a > T(b)){ a = b; return 1; } return 0; } template bool chmax(T& a, const U& b){ if(a < T(b)){ a = b; return 1; } return 0; } using U = uint64_t; const U B = 64; struct FS { U n; vector> a; vector cnt; FS(U n) : n(n),cnt(n,0) { do a.emplace_back(n = (n + B - 1) / B); while(n > 1); } bool operator[](ll i) const { return a[0][i / B] >> (i % B) & 1; } void set(ll i) { cnt[i]++; if(cnt[i] != 1){return;} for(auto& v : a) { v[i / B] |= 1ULL << (i % B); i /= B; } } void erase(ll i) { cnt[i]--; if(cnt[i] != 0){return;} for(auto& v : a) { v[i / B] &= ~(1ULL << (i % B)); if(v[i / B]) break; i /= B; } } ll next(ll i) { rep(h, len(a)) { i++; if(i / B >= a[h].size()) break; U d = a[h][i / B] >> (i % B); if(d) { i += countr_zero(d); while(h--) i = i * B + countr_zero(a[h][i]); return i; } i /= B; } return n; } ll prev(ll i) { rep(h, len(a)) { i--; if(i < 0) break; U d = a[h][i / B] << (~i % B); if(d) { i -= countl_zero(d); while(h--) i = i * B + __lg(a[h][i]); return i; } i /= B; } return -1; } }; using pii = pair; struct Mo { int n; vector lr; Mo(int n) : n(n) {} void add(int l, int r) { lr.emplace_back(l, r); } template void build(const AL& add_left, const AR& add_right, const EL& erase_left, const ER& erase_right, const O& out) { int q = (int)lr.size(); int bs = n / min(n, sqrt(q)); vector ord(q); iota(all(ord), 0); sort(all(ord), [&](int a, int b) { int ab = lr[a].first / bs, bb = lr[b].first / bs; if(ab != bb) return ab < bb; return (ab & 1) ? lr[a].second > lr[b].second : lr[a].second < lr[b].second; }); int l = 0, r = 0; for(auto idx : ord) { while(l > lr[idx].first) add_left(--l); while(r < lr[idx].second) add_right(r++); while(l < lr[idx].first) erase_left(l++); while(r > lr[idx].second) erase_right(--r); out(idx); } } template void build(const A& add, const E& erase, const O& out) { build(add, add, erase, erase, out); } }; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); LL(n,q); VLL(a,n); Mo mo(100000); vll tl(q),il(q),xl(q); ll cnt = 0; rep(i,q){ LL(t); if(t == 1){ LL(idx,x); tl[i] = t; il[i] = idx-1; xl[i] = x; } else{ LL(r); tl[i] = t; il[i] = r; mo.add(i,r); cnt++; } } multiset s,t; auto add = [&](ll x){ debug("Add"); /* for(auto z:s){ cerr << z << ' '; } cerr << endl; for(auto z:t){ cerr << z << ' '; } cerr << endl; cerr << x << endl; */ s.emplace(x); auto it = s.find(x); if(it != s.begin()){ t.emplace((*it) ^ (*(prev(it)))); } if(next(it) != s.end()){ t.emplace((*it) ^ (*(next(it)))); } if(it != s.begin() && next(it) != s.end()){ t.erase(t.find((*(prev(it))) ^ (*(next(it))))); } /* for(auto z:s){ cerr << z << ' '; } cerr << endl; for(auto z:t){ cerr << z << ' '; } cerr << endl; cerr << x << endl; */ }; auto del = [&](ll x){ debug("Del"); /* for(auto z:s){ cerr << z << ' '; } cerr << endl; for(auto z:t){ cerr << z << ' '; } cerr << endl; cerr << x << endl; */ auto it = s.find(x); if(it != s.begin()){ t.erase(t.find((*it) ^ (*(prev(it))))); } if(next(it) != s.end()){ t.erase(t.find((*it) ^ (*(next(it))))); } if(it != s.begin() && next(it) != s.end()){ t.emplace((*(prev(it))) ^ (*(next(it)))); } s.erase(s.find(x)); debug("Del"); /* for(auto z:s){ cerr << z << ' '; } cerr << endl; for(auto z:t){ cerr << z << ' '; } cerr << endl; cerr << x << endl; */ }; vvll b(n); rep(i,n){ b[i].push_back(a[i]); } ll right = 0; auto add_left = [&](ll i){ debug("add_left",i); debug(a); if(tl[i] == 2){return;} ll idx = il[i]; ll x = xl[i]; if(idx < right)del(a[idx]); b[idx].pop_back(); a[idx] = b[idx].back(); if(idx < right)add(a[idx]); }; auto del_left = [&](ll i){ debug("del_left",i); debug(a); if(tl[i] == 2){return;} ll idx = il[i]; ll x = xl[i]; if(idx < right)del(a[idx]); a[idx] = x; b[idx].push_back(x); if(idx < right)add(a[idx]); }; auto add_right = [&](ll i){ debug("add_right",i); right++; add(a[i]); }; auto del_right = [&](ll i){ debug("del_right",i); right--; del(a[i]); }; vll ans(q,0); auto out = [&](ll i){ ans[i] = *(t.begin()); debug("out",i,ans[i]); debug("Out"); /* for(auto z:s){ cerr << z << ' '; } cerr << endl; for(auto z:t){ cerr << z << ' '; } */ }; debug(1); mo.build(add_left,add_right,del_left,del_right,out); ans.resize(cnt); rep(i,cnt){ print(ans[i]); } }