#include <bits/stdc++.h>

#define int long long int
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

using namespace std;

signed main()
{   ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a;
    vector<int> cnt(31,0);
  //  cout << (1LL << 30);
    for(int i = 0;i<n;i++){
        int x;
        cin >> x;
        a.push_back(x);
        for(int j = 0;j<=30;j++){
            if(x&(1LL << j)){
                cnt[j]++;
            }
        }
    }
   // sort(a.begin(),a.end());
   // cout << (1LL << 30);
    /*cout << "Prvi: ";
    for(int i = 0;i<=30;i++){
        cout << cnt[i] << " ";
    }
    cout << endl;*/
    /*for(int i = 0;i<b.size();i++){
        cout << b[i] << " ";
    }
    cout << endl;*/
    int q;
    cin >> q;
    int broj = 0;
    while(q--){
        int t,k;
        cin >> t >> k;
        if(t==0){
            broj = 0;
            for(int i = 0;i<=30;i++){
           //     cout << cnt[i] << " ";
                if(cnt[i]>=k && cnt[i]>0){
                    broj+=(1LL<<i);
                }
            }
           // cout << endl;
            cout << broj << "\n";
        }else{
            int x;
            cin >> x;
            for(int i = 0;i<=30;i++){
                if((a[k-1]&(1LL<<i)) &&  !(x&(1LL<<i))){
                    cnt[i]--;
                }else if(!(a[k-1]&(1LL<<i)) && (x&(1LL<<i))){
                    cnt[i]++;
                }
            }
            a[k-1] = x;
        }
    }
    return 0;
}