#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define all(x) (x).rbegin(),(x).rend()
#define fi first
#define si second
#define pii pair<int,int>

using namespace std;

const int maxn=1e5+10;

int n;
vector<int> arr,res;

void resi(vector<int>niz){
    sort(all(niz));
    int l=0,r=1;
    res=niz;
    while(r<n){
        if((res[l]|res[r])>res[l]){
            int a=res[l],b=res[r];
            res[r]=a&b;
            res[l]=a|b;
            r++;
        }
        else r++;
        if(r==n){l++;r=l+1;}
    }
    sort(all(res));
}

int main()
{
    speed;
    bool all1=true,promena=true;
    cin>>n;
    int br1=0;
    arr=vector<int>(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i]>1)all1=false;
        else if(arr[i]==1)br1++;
    }
    if(all1){
        int q;
        cin>>q;
        while(q--){
            int c;
            cin>>c;
            if(c){
                int k,x;
                cin>>k>>x;
                k--;
                if(arr[k]==0&&x==1)br1++;
                else if(arr[k]==1&&x==0)br1--;
                arr[k]=x;
            }
            else{
                int k;
                cin>>k;
                if(br1>=k)cout<<1<<endl;
                else cout<<0<<endl;
            }
        }
    }
    else{
        int q;
        cin>>q;
        while(q--){
            int c;
            cin>>c;
            if(c){
                int k,x;
                cin>>k>>x;
                arr[k-1]=x;
                promena=true;
            }
            else{
                if(promena){
                    resi(arr);
                    promena=false;
                }
                int k;
                cin>>k;
                cout<<res[k-1]<<endl;
            }
        }
    }
    return 0;
}