/* In The Name of Allah */
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll ;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define int long long

const int N=2e5+14, inf=INT_MAX, Mod=1e9+7;
int n,q,a[N],k,kind,x[2];
int32_t main(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>q;
	for(int i=0;i<n;i++){
        cin>>a[i];
        x[a[i]]++;
	}

    for(int i=0;i<q;i++){
        cin>>kind>>k;
        if(kind==1){
            x[a[k-1]]--;
            a[k-1]=1-a[k-1];
            x[a[k-1]]++;
        }
        else{
            if(k>x[1])
                cout<<0<<'\n';
            else
                cout<<1<<'\n';
        }


    }
}
