#include <bits/stdc++.h>

using namespace std;

const int bits = 32;


int counts[bits] = {0};


void update(int num, bool add){
    int bit_i = 0;
    while (num != 0){
        if (num & 1){
            if (add) counts[bit_i]++;
            else counts[bit_i]--;
        }
        bit_i++;
        num >>= 1;
    }
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> nums(n);
    for (int i = 0; i < n; i++){
        cin >> nums[i];
        update(nums[i], true);
    }
    int q, t, k, x;
    cin >> q;
    for (int query = 0; query < q; query++){
        cin >> t >> k;
        if (t == 0){
            x = 0;
            for (int bit_i = bits - 1; bit_i >= 0; bit_i--){
                if (counts[bit_i] >= k) x += 1;
                if (bit_i != 0) x <<= 1;
            }
            cout << x << endl;
        }
        else{
            k--;
            cin >> x;
            update(nums[k], false);
            update(x, true);
            nums[k] = x;
        }
    }
    return 0;
}