#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if(sizeof...(t)) cerr << ", "; DBG(t...);}
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

const int N = 1e5 + 3;
const int B = 31;
ll freq[B];
ll a[N];

void solve() {
    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        for (int j = 0; j < B; j++) {
            if (a[i] & (1 << j))
                freq[j]++;
        }
    }

    auto napravi = [&](int k) {
        ll ans = 0;
        for (int i = 0; i < B; i++) {
            if (freq[i] >= k) {
                ans += (1ll << i);
                //dbg(freq[i]);
            }
        }
        return ans;
    };

    int q; cin >> q;
    while (q--) {
        int type; cin >> type;
        if (type == 0) {
            ll k; cin >> k;
            cout << napravi(k) << "\n";
        } else {
            ll k, x; cin >> k >> x;
            for (int j = 0; j < B; j++) {
                if (a[k] & (1ll << j))
                    freq[j]--;
            }
            for (int j = 0; j < B; j++) {
                if (x & (1ll << j))
                    freq[j]++;
            }
        }
    }
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int t=1; //cin >> t;
    while (t--) {
        solve();
    }
}