#include <bits/stdc++.h>

#define maxn 100001

typedef long long ll;

using namespace std;

ll n;
ll arr[maxn];
ll bitovi[18];

void promeni(ll k) {
	ll x, j;
	cin >> x;
	ll a = arr[k - 1], b = x;
	j = 0;
	while(a > 0) {
		bitovi[j] -= (a & 1);
		a = a >> 1;
		j++;
	}
	j = 0;
	while(b > 0) {
		bitovi[j] += (b & 1);
		b = b >> 1;
		j++;
	}
	arr[k - 1] = x;
}

void rekonstrukcija(ll k) {
	ll c = 1, br = 0;
	for(ll i = 0; i < 18; i++) {
		if(bitovi[i] >= k) {
			br += c;
		}
		c = c << 1;
	}
	cout << br << "\n";
}

void prep() {
	memset(bitovi, 0, sizeof(bitovi));
	for(ll i = 0; i < n; i++) {
		ll j = 0, cur = arr[i];
		while(cur > 0) {
			bitovi[j] += (cur & 1);
			cur = cur >> 1;
			j++;
		}
	}
}

void solve() {
	ll t, k;
	cin >> t >> k;
	if(t == 1) promeni(k);
	else rekonstrukcija(k);
}

int main() {
	ll q;
	cin >> n;
	for(ll i = 0; i < n; i++) cin >> arr[i];
	prep();
	cin >> q;
	while(q--) solve();
	return 0;
}