#include <bits/stdc++.h>

#define ll long long
#define loop(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

void get_max_lex(vector<ll> &array, ll index = 0)
{
    if (index == array.size() - 1)
        return;

    ll k0 = array[index];

    // TODO: Optimizuj ovo na ST i RUQ za O(NQlogN)
    loop(i, index + 1, array.size())
    {
        if ((array[index] | array[i]) == array[index])
            continue;
        array[index] |= array[i];
        array[i] &= k0; // Ovo ne valja
    }

    return get_max_lex(array, index + 1);
}

void copy_arr(const vector<ll> &src, vector<ll> &out)
{
    loop(i, 0, src.size())
    {
        out[i] = src[i];
    }
}

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

    ll n, q, t, k, x, o = 0;
    bool changed = true;
    bool p4 = true;
    cin >> n;
    vector<ll> a(n);
    vector<ll> out(n);
    loop(i, 0, n)
    {
        cin >> a[i];
        if (a[i]) o++;
        if (a[i] > 1) p4 = false;
    }

    cin >> q;
    loop(i, 0, q)
    {
        cin >> t >> k;
        k--;

        if (p4) {
            if (t == 1)
            {
                cin >> x;
                if (a[k] != x) {
                    a[k] = x;
                    if (x == 1) o++;
                    else o--;
                }
            } else {
                if (k < o) cout << "1\n";
                else cout << "0\n";
            }
        } else {
            if (t == 1)
            {
                cin >> x;
                a[k] = x;
                changed = true;
            }
            else
            {
                if (changed)
                {
                    copy_arr(a, out);
                    get_max_lex(out);
                    changed = false;
                }

                cout << out[k] << '\n';
            }
        }
    }

    return 0;
}