#include <iostream>


using namespace std;

long long x[200000];
long long bitovi[50];

int main()
{
    /*
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    */

    long long a,b,x1,stepen,br,I,i;
    long long n;

    cin >> n;

    for(i=0;i<n;i++){

    cin>>x[i];

    x1=x[i];
    stepen=0;

    while(x1>0){

    if(x1%2==1)
    bitovi[stepen]++;

    x1=x1/2;
    stepen++;

    }

    }

    /*
    for(i=0;i<5;i++){

    cout << i << " " << bitovi[i] << '\n';

    }
    */

    long long  q ,tt,kk,xx,u;

    cin >> q;

    for(I=0;I<q;I++){

    cin >> tt;

    if(tt==0){

    u = 0;
    stepen = 0;
    br = 1;

    cin >> kk;

    for(stepen=0;stepen<48;stepen++){

    if(bitovi[stepen]>=kk)
    u = u + br;

    br = br * 2;

    }

    cout << u << '\n';

    }
    else{

    cin >> kk >> xx;

    stepen = 0;

    kk--;

    x1=x[kk];

    while(x1>0){

    if(x1%2==1)
    bitovi[stepen]--;

    x1=x1/2;
    stepen++;

    }

    x[kk] = xx;

    stepen = 0;
    x1=xx;

    while(x1>0){

    if(x1%2==1)
    bitovi[stepen]++;

    x1=x1/2;
    stepen++;

    }


    }


    }


    return 0;


}