#include <bits/stdc++.h>
#define maxCif 32

using namespace std;

vector<int> a;
vector<int> solout;

int spc[maxCif];

int main()
{
    int n;
    cin >> n;

    for(int i = 0; i < n; i++)
    {
        int ai;
        cin >> ai;
        a.push_back(ai);
    }
    memset(spc, 0, sizeof(spc));

    for(int i = 0; i < n; i++)
    {
        int apriv = a[i];

        int indcif = 0;
        while(apriv > 0)
        {
            spc[indcif] += apriv % 2;
            apriv /= 2;
            indcif++;
        }

    }

    int q;
    cin >> q;

    for(int i = 0; i < q; i++)
    {
        int t;

        cin >> t;

        if(t == 0)
        {
            int k;
            cin >> k;
            int br = 0;

            for(int i = 0; i < maxCif; i++)
            {
                if(spc[i] >= k)
                {
                    br += 1 << i;
                }
            }
            solout.push_back(br);
        }
        else
        {
            int k;
            int x;

            cin >> k;
            cin >> x;

            int atrenutno = a[k - 1];

            int indcif2 = 0;
            while(atrenutno > 0)
            {
                spc[indcif2] -= atrenutno % 2;
                indcif2++;
                atrenutno /= 2;
            }

            a[k - 1] = x;

            indcif2 = 0;
            while(x > 0)
            {
                spc[indcif2] += x % 2;
                indcif2++;
                x /= 2;
            }
        }
    }

    for(int i = 0; i < solout.size(); i++)
    {
        cout << solout[i] << '\n';
    }

    return 0;
}