#include<bits/stdc++.h>
#define lli long long
using namespace std;

void solve(){
    int n,q;
    cin>>n>>q;
    int arr[n];
    int cnt0=0,cnt1=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        if(arr[i]==0)
        {
            cnt0++;
        }
        else
        {
            cnt1++;
        }
    }

    while(q--)
    {
        int test,x;
        cin>>test>>x;

        if(test==1)
        {
            if(arr[x-1]==1)
            {
                arr[x-1]=0;
                cnt0++;
                cnt1--;
            }
            else
            {
                arr[x-1]=1;
                cnt1++;
                cnt0--;
            }
        }

        else
        {
            if(x<=cnt1)
            {
                cout<<"1"<<endl;
            }
            else
            {
                cout<<"0"<<endl;
            }
        }
    }

}

int main(){


    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}