#include <bits/stdc++.h>

#define ll long long
#define pii pair<int, int>
#define xx first
#define yy second
#define pb push_back
#define MAXN 200010

using namespace std;

int n, a[MAXN], cnt[40];

int main()
{
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i];

    for (int i=1; i<=n; i++)
    {
        int x=a[i];
        int k=0;
        while (x)
        {
            if (x%2) cnt[k]++;
            x/=2;
            k++;
        }
    }

    int q; cin>>q;
    while (q--)
    {
        int t; cin>>t;
        if (t==1)
        {
            int i, x; cin>>i>>x;
            int pom=a[i];
            int k=0;
            while (pom)
            {
                if (pom%2) cnt[k]--;
                pom/=2;
                k++;
            }
            a[i]=x;
            k=0;
            while (x)
            {
                if (x%2) cnt[k]++;
                x/=2;
                k++;
            }
        }
        else
        {
            int i; cin>>i;
            ll ress=0;
            for (ll k=0; k<30; k++)
            {
                if (cnt[k]>=i) ress+=(ll)(1<<k);
            }
            cout<<ress<<endl;
        }
    }
}