#include <bits/stdc++.h>
#define MAXN 100010
using namespace std;

vector<int> a(MAXN);
vector<int> b(MAXN);
int n;
map<int, int> mapa;

void solve(int k, vector<int> niz, map<int, int> kopija){
    b = niz;
    for(int i = 0; i < n; i++){
        int zbir = 0;
        for(auto x : kopija){
            if(x.second > 0 && x.first != 0 && !((x.first & zbir) == x.first)){
                kopija[x.first]--;
                kopija[x.first & zbir]++;
                zbir = zbir | x.first;
            }
        }
        b[i] = zbir;
    }
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		mapa[a[i]]++;
	}
	int q; cin >> q;
	int brojac = 0;
	int pamti = 0;
	while(q--){
		int t, k; cin >> t >> k;
		if(t == 1){
			int x; cin >> x;
			mapa[a[k-1]]--;
			mapa[x]++;
			a[k-1] = x;
			brojac++;
		}
		else{
            if(mapa[0] + mapa[1] != n) solve(k, a, mapa);
            else{
                b = a;
                sort(b.begin(), b.end(), greater<int>());
            }
            cout<<b[k-1]<<'\n';
		}
	}
}