#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10, LOG = 30;
int n, q;
int a[N];
int cnt[LOG];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        for(int j = 0; j < LOG; j++) if(a[i] & (1 << j)) cnt[j]++;
    }
    cin >> q;
    while(q--) {
        int t;
        cin >> t;
        if(t == 0) {
            int ind;
            cin >> ind;
            int ans = 0;
            for(int i = 0; i < LOG; i++) if(cnt[i] >= ind) ans += (1 << i);
            cout << ans << "\n";
        } else {
            int ind, val;
            cin >> ind >> val;
            for(int i = 0; i < LOG; i++) {
                if(a[ind] & (1 << i)) cnt[i]--;
                if(val & (1 << i)) cnt[i]++;
            }
            a[ind] = val;
        }
    }
    return 0;
}