#include <bits/stdc++.h>

using namespace std;

#define ll long long
const int INF=1e9;
const ll LINF=1e18;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mid ((l+r)/2)
#define sz(a) (int((a).size()))
#define all(a) a.begin(),a.end()
#define endl "\n"
#define pb push_back

void PRINT(int x) {cerr << x;}
void PRINT(ll x) {cerr << x;}
void PRINT(double x) {cerr << x;}
void PRINT(char x) {cerr << '\'' << x << '\'';}
void PRINT(string x) {cerr << '\"' << x << '\"';}
void PRINT(bool x) {cerr << (x ? "true" : "false");}

template<typename T,typename V>
void PRINT(pair<T,V>& x){
    cerr<<"{";
    PRINT(x.fi);
    cerr<<",";
    PRINT(x.se);
    cerr<<"}";
}
template<typename T>
void PRINT(T &x){
    int id=0;
    cerr<<"{";
    for(auto _i:x){
        cerr<<(id++ ? "," : "");
        PRINT(_i);
    }
    cerr<<"}";
}
void _PRINT(){
    cerr<<"]\n";
}
template<typename Head,typename... Tail>
void _PRINT(Head h,Tail... t){
    PRINT(h);
    if(sizeof...(t)) cerr<<", ";
    _PRINT(t...);
}

#define Debug(x...) cerr<<"["<<#x<<"]=["; _PRINT(x)

const int LOG=29;

int main(){
    int N; cin>>N;
    vector<int> a(N+1);
    for(int i=1;i<=N;i++) cin>>a[i];
    vector<int> cnt(LOG+1,0);
    for(int i=1;i<=N;i++){
        for(int b=0;b<=LOG;b++){
            if(a[i]&(1<<b)){
                cnt[b]++;
            }
        }
    }
    int Q; cin>>Q;
    while(Q--){
        int t; cin>>t;
        if(t==0){
            int k; cin>>k;
            int res=0;
            for(int b=0;b<=LOG;b++){
                if(cnt[b]>=k){
                    res+=(1<<b);
                }
            }
            cout<<res<<endl;
        }
        else{
            int k,x; cin>>k>>x;
            for(int b=0;b<=LOG;b++){
                if(a[k]&(1<<b)) cnt[b]--;
                if(x&(1<<b)) cnt[b]++;
            }
        }
    }
    return 0;
}