#include <iostream>
#include <unordered_map>
#include <map>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <limits>
#include <algorithm>

#define ll long long

//#include <bits/stdc++.h>

/*
bool check(std::vector<std::vector<char>>& p, ll u, ll v) {
    if (seen[u] || seen[v]) return false;
    seen[u] = true;
    seen[v] = true;
    for (auto it = paths[u].begin(); it != paths[u].end(); it++) {
        char c = it->first;
        std::vector<ll> pp = it->second;

        for (ll p = 0; p < pp.size(); p++) {
            auto finv = paths[pp[p]][c];
            if (finv.size() > 0) {

                for (ll i = 0; i < finv.size(); i++) {

                }
            }
        }
    }
}*/

std::vector<ll> getlex(std::vector<ll> arr) {
    ll n = arr.size();
    std::sort(arr.begin(), arr.end());
    std::vector<ll> lex;
    ll it = n-1;
    while (it > 0) {
        if (arr[it] != 0) {
            ll curr = arr[it];
            arr[it] = 0;
            for (ll i = it-1; i >= 0; i--) {
                    //std::cout << "Checking " << curr << " " << arr[i] << " " << (curr | arr[i]) << std::endl;
                if (curr | arr[i] > curr) {
                    ll t = curr;
                    curr |= arr[i];
                    arr[i] = t & arr[i];
                }
            }
            //std::cout << "At " << it << " " << curr << std::endl;
            lex.push_back(curr);
        }
        it--;
    }
    //std::cout << lex.size() << " size" << std::endl;
    return lex;
}
int main()
{
    std::ios::sync_with_stdio(false);
    /*std::cin.tie(0);
    std::cout.tie(0);*/

    ll n;
    std::cin >> n;

    std::vector<ll> arr(n);
    /*ll one = 0;
    for (ll i = 0; i < n; i++) {
        std::cin >> arr[i];
        if (arr[i] == 1) one++;
    }*/
    bool oz = true;
    int one = 0;
    for (ll i = 0; i < n; i++) {
        std::cin >> arr[i];
        if (arr[i] > 1) oz = false;
        if (arr[i] == 1) one++;
    }

    if (oz) {
        int q;
        std::cin >> q;
        for (int i = 0; i < q; i++) {
            int a, b;
            std::cin >> a >> b;
            b--;
            if (a == 1) {
                int c;
                std::cin >> c;
                if (arr[b] == 1 && c == 0) {
                    one--;
                    arr[b] = 0;
                }
                else if (arr[b] == 0 && c == 1) {
                    one++;
                    arr[b] = 1;
                }
                else {
                    arr[b] = c;
                }
            }
            else {
                std::cout << ((b+1) <= one) << std::endl;
            }
        }
        return 1;
    }

    std::vector<ll> lex = getlex(arr);

    ll q;
    std::cin >> q;
    for (ll i = 0; i < q; i++) {
        ll a, b;
        std::cin >> a >> b;
        b--;
        if (a == 1) {
            ll c;
            std::cin >> c;
            arr[b] = c;
            lex = getlex(arr);
            /*if (arr[b] == 1 && c == 0) {
                one--;
                arr[b] = 0;
            }
            else if (arr[b] == 0 && c == 1) {
                one++;
                arr[b] = 1;
            }
            else {
                arr[b] = c;
            }*/
        }
        else {
            //std::cout << ((b+1) <= one) << std::endl;
            if (b >= lex.size()) {
                std::cout << 0 << std::endl;
            }
            else{
                std::cout << lex[b] << std::endl;
            }
        }
    }

    return 0;
}