#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using str = string;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vpl = vector<pl>;
using vvi = vector<vi>;
using vvl = vector<vl>;
#define f first
#define s second
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define sor(x) sort(all(x))
#define lb lower_bound
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

void solve(){
    ll n;
    cin >> n;
    vl v(n), cnt(32);
    F0R(i, n){
        cin >> v[i];
        ll k = 0;
        for(ll j = v[i]; j > 0; j /= 2){
            cnt[k] += (j % 2);
            k++;
        }
    }
    ll q;
    cin >> q;
    F0R(i, q){
        ll x, k;
        cin >> x >> k;
        k--;
        if(x == 0){
            ll sol = 0LL, c = 1LL;
            F0R(j, 31){
                if(cnt[j] > k)sol += c;
                c *= 2;
            }
            cout << sol << "\n";
        }
        else if(x == 1){
            ll t;
            cin >> t;
            ll p = 0;
            for(ll j = v[k]; j > 0; j /= 2){
                cnt[p] -= (j % 2);
                p++;
            }
            v[k] = t;
            p = 0;
            for(ll j = v[k]; j > 0; j /= 2){
                cnt[p] += (j % 2);
                p++;
            }
        }
    }
}


int main()
{
    //ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t; t = 1;while(t--){
        solve();
    }
    return 0;
}