#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){
    //cerr<<"RESI__________"<<endl;
    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));
    //cerr<<"IZASAO________"<<endl;
}

int main()
{
    speed;
    bool promena=true;
    cin>>n;
    if(n>5000)return 0;
    arr=vector<int>(n);
    for(int i=0;i<n;i++)cin>>arr[i];
    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;/*
                cerr<<"NOVI NIZ________________"<<endl;
                for(int i=0;i<n;i++){
                    cout<<res[i]<<" ";
                }
                cerr<<endl<<"_____________________"<<endl;
                */
            }
            int k;
            cin>>k;
            cout<<res[k-1]<<endl;
        }
    }
    return 0;
}
/*
5
1 1 1 1 1
9
2 5
1 5 0
1 4 0
2 1
1 3 0
1 2 0
1 1 0
2 4
2 1
*/