#include <bits/stdc++.h>
#define int long long

using namespace std;

void printajniz(vector<int>a, int n, int x){
    for (int i=0;i<n;i++){
        for (int j=i+1;j<n;j++){
            int op1 = (a[i] & a[j]);
            int op2 = (a[i] | a[j]);
            a[i] = op1;
            a[j] = op2;
        }
    }
    //for (auto t : a) cout <<t<<' ';
    //cout <<'\n';
    cout <<a[x]<<'\n';
}

void solve(){
    int n; cin >> n;
    vector<int>a(n); for (auto &t : a) cin >> t;
    int q; cin >> q;
    while (q--){
        int t,k; cin >> t >> k;
        if (t == 0) printajniz(a,n,(n - k));
        else{
            int x; cin >> x;
            k--;
            for (int i=0;i<n;i++){
                int op1 = (a[i] & a[k]);
                int op2 = (a[i] | a[k]);
                if (op2 == x){
                    a[k] = op2;
                    a[i] = op1;
                    break;
                }
                else if (op1 == x){
                    a[k] = op1;
                    a[i] = op2;
                    break;
                }
            }
        }
    }
}



int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int t = 1; //cin >> t;
    while (t--){
        solve();
    }
    return 0;
}