#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
long long a[1000001], b[1000001];
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //nt a = 1<<10;
    //cout << a;
    /*int m, a, b;
    cin >> a >> b;
    int c = a&b, d = a|b;
    cout << c << " " << d;*/
    long long n, q, t, k, x, i, j, bi, bj;
    bool bul = true;
    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] != 0 || a[i] != 1) bul = false;
    }
    cin >> q;
    if (bul)
    {
        long long br = 0;
        for(i = 0; i < n; i++)
        {
            if (a[i] == 1) br++;
        }
        while (q--)
        {
            cin >> t >> k;
            if (t == 1)
            {
                cin >> x;
                if (x == 1 && a[k-1] == 0) br++;
                if (x == 0 && a[k-1] == 1) br--;
                a[k-1] = x;
                continue;
            }
            if (k > br) cout << 0 << endl;
            else cout << 1 << endl;
        }
    }
    else //srediti
    {
        while (q--)
        {
        cin >> t >> k;
        if (t == 1)
        {
            cin >> x;
            a[k-1] = x;
            continue;
        }
        for (i = 0; i < n; i++)
        {
            b[i] = a[i];
        }
        for (i = 0; i < n; i++)
        {
            for (j = i+1; j < n; j++)
            {
                bi = max(b[i]&b[j],b[i]|b[j]);
                bj = min(b[i]&b[j],b[i]|b[j]);
                b[i] = bi; b[j] = bj;
            }
        }
        cout << b[k-1] << endl;
    }
    }
    return 0;
}