#include using namespace std; using ll = long long; using pii = pair; using pll = pair; using vi = vector; using vl = vector; #define ov4(a, b, c, d, name, ...) name #define rep3(i, a, b, c) for(ll i = (a); i < (b); i += (c)) #define rep2(i, a, b) rep3(i, a, b, 1) #define rep1(i, n) rep2(i, 0, n) #define rep0(n) rep1(aaaaa, n) #define rep(...) ov4(__VA_ARGS__, rep3, rep2, rep1, rep0)(__VA_ARGS__) #define per(i, a, b) for(ll i = (a)-1; i >= (b); i--) #define fore(e, v) for(auto&& e : v) #define all(a) begin(a), end(a) #define si(a) (int)(size(a)) #define lb(v, x) (lower_bound(all(v), x) - begin(v)) #define eb emplace_back template bool chmin(T& a, const S& b) { return a > b ? a = b, 1 : 0; } template bool chmax(T& a, const S& b) { return a < b ? a = b, 1 : 0; } const int INF = 1e9 + 100; const ll INFL = 3e18 + 100; #define i128 __int128_t using U = uint64_t; static constexpr int B = 64; struct FS { int n; // 元のサイズ vector> a; // a[0]: leaf vector cnt; // multiset 用 FS(int _n = 0) { init(_n); } void init(int _n) { n = _n; cnt.assign(n, 0); a.clear(); int m = n; while (true) { a.emplace_back((m + B - 1) / B, 0); if (m <= 1) break; m = (m + B - 1) / B; } } // 存在確認 bool contains(int i) const { return (a[0][i / B] >> (i % B)) & 1; } // 挿入(multiset) void insert(int i) { if (++cnt[i] > 1) return; for (int h = 0; h < (int)a.size(); h++) { a[h][i / B] |= 1ULL << (i % B); i /= B; } } // 削除(multiset) void erase(int i) { if (--cnt[i] > 0) return; for (int h = 0; h < (int)a.size(); h++) { int idx = i / B; U before = a[h][idx]; a[h][idx] &= ~(1ULL << (i % B)); if (before != a[h][idx]) { if (a[h][idx]) break; } i /= B; } } // x より大きい最小要素(なければ n) int next(int x) const { int i = x + 1; for (int h = 0; h < (int)a.size(); h++) { if (i >= (int)a[h].size() * B) return n; int idx = i / B; U d = a[h][idx] & (~0ULL << (i % B)); if (d) { int pos = __builtin_ctzll(d); i = idx * B + pos; while (h--) { i = i * B + __builtin_ctzll(a[h][i]); } return i; } i = (idx + 1) * B; } return n; } // x より小さい最大要素(なければ -1) int prev(int x) const { int i = x - 1; for (int h = 0; h < (int)a.size(); h++) { if (i < 0) return -1; int idx = i / B; U d = a[h][idx] & ((1ULL << ((i % B) + 1)) - 1); if (d) { int pos = 63 - __builtin_clzll(d); i = idx * B + pos; while (h--) { i = i * B + (63 - __builtin_clzll(a[h][i])); } return i; } i = idx * B - 1; } return -1; } }; int main() { int n,q; cin >> n >> q; vector a(n); for(int i = 0; i < n; i++)cin >> a[i]; int B = 600; vector pref_s((n + B - 1) / B,FS(1<<20)); vector pref_t((n + B - 1) / B,FS(1<<20)); auto add = [&](FS &S, FS &T, int x)->void { S.insert(x); /* auto it = S.find(x); if(it != S.begin()){ auto it2 = it; it2--; T.insert(*it ^ *it2); } */ if(S.next(-1) != x){ T.insert(x ^ S.prev(x)); } /* auto it2 = it; it2++; if(it2 != S.end()){ T.insert(*it ^ *it2); } */ if(S.prev(1<<20) != x){ T.insert(x ^ S.next(x)); } if(S.next(-1) != x && S.prev(1<<20) != x){ T.erase(S.prev(x) ^ S.next(x)); } }; auto del = [&](FS &S, FS &T, int x)->void { /* auto it = S.find(x); if(it != S.begin()){ auto it2 = it; it2--; T.insert(*it ^ *it2); } */ if(S.next(-1) != x){ T.erase(x ^ S.prev(x)); } /* auto it2 = it; it2++; if(it2 != S.end()){ T.insert(*it ^ *it2); } */ if(S.prev(1<<20) != x){ T.erase(x ^ S.next(x)); } if(S.next(-1) != x && S.prev(1<<20) != x){ T.insert(S.prev(x) ^ S.next(x)); } S.erase(x); /* auto it = S.find(x); if(it != S.begin()){ auto it2 = it; it2--; T.erase(T.find(*it ^ *it2)); } auto it2 = it; it2++; if(it2 != S.end()){ T.erase(T.find(*it ^ *it2)); } if(it != S.begin() && it2 != S.end()){ auto it3 = it; it3--; T.insert(*it2 ^ *it3); } S.erase(it); */ }; vector> v_s((n + B - 1) / B); for(int i = 0; i < n; i++){ for(int j = (n + B - 1) / B - 1; i < (j+1) * B; j--){ //if(i < (j+1) * B)add(pref_s[j], pref_t[j], a[i]); v_s[j].push_back(a[i]); } } for(int i = 0; i < (n + B - 1) / B; i++){ sort(v_s[i].begin(), v_s[i].end()); for(int j = 0; j < (int)v_s[i].size(); j++){ if(j != 0){ pref_t[i].insert(v_s[i][j] ^ v_s[i][j-1]); } pref_s[i].insert(v_s[i][j]); } } while(q--){ int type; cin >> type; if(type == 1){ int i; cin >> i; int x; cin >> x; --i; for(int j = (n + B - 1) / B - 1; i < (j+1) * B; j--){ del(pref_s[j], pref_t[j], a[i]); } a[i] = x; for(int j = (n + B - 1) / B - 1; i < (j+1) * B; j--){ add(pref_s[j], pref_t[j], a[i]); } } else { int ans = 1LL<<30; int r; cin >> r; --r; if(r / B != 0){ //ans = *pref_t[r/B-1].begin(); ans = pref_t[r/B-1].next(-1); for(int i = r / B * B; i <= r; i++){ /* auto it = pref_s[r/B-1].lower_bound(a[i]); if(it != pref_s[r/B-1].end()){ ans = min(ans, (*it) ^ (a[i])); } if(it == pref_s[r/B-1].begin())continue; it--; ans = min(ans , (*it) ^ (a[i])); */ if(pref_s[r/B-1].prev(1<<20) != a[i]){ ans = min(ans, (pref_s[r/B-1].next(a[i])) ^ a[i]); } if(pref_s[r/B-1].next(-1) != a[i]){ ans = min(ans, (pref_s[r/B-1].prev(a[i])) ^ a[i]); } } } vector v; for(int i = r / B * B; i <= r; i++){ v.push_back(a[i]); } sort(v.begin(), v.end()); for(int i = 0; i < (int)v.size() - 1; i++){ ans = min(ans , (v[i] ^ v[i+1])); } cout << ans << endl; } } }