#include <bits/stdc++.h>
#define pc pair<int, char>
#define f first
#define s second
#define ll long long

using namespace std;

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

    int n;cin>>n;
    ll a[n+10];
    vector<ll>cnt(70, 0);
    for(int i = 0; i<n; i++)
    {
        cin>>a[i];

        for(int j = 0; j<=60; j++)
        {
            if((1LL<<j)&a[i])cnt[j]++;
        }
    }
    int q;cin>>q;
    while(q--)
    {
        int t;cin>>t;
        if(t==0)
        {
            int x;cin>>x;
            ll c = 0;
            vector<int>cnt1(70, 0);
            for(int i = 0; i<=30; i++)
            {
                cnt1[i]=cnt[i];
                c+=cnt[i];
            }
            vector<ll>nums;
            while(true)
            {
                ll cur = 0;
                for(int i = 0; i<=30; i++)
                {

                    if(cnt1[i])
                    {
                        cur+=(1LL<<i);
                        cnt1[i]--;
                    }
                }
                if(cur==0)break;
                nums.push_back(cur);
            }
            sort(nums.rbegin(), nums.rend());
            x--;
            if(x>=nums.size())cout<<"0\n";
            else cout<<nums[x]<<"\n";
            //cout<<"----------\n";

        }else
        {
            int x, y;cin>>x>>y;
            for(int j = 0; j<=30; j++)
            {
                if((1<<j)&a[x-1])cnt[j]--;
                if((1<<j)&y)cnt[j]++;
            }
            a[x-1]=y;

        }
    }
    return 0;
}