#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair<long long int,long long int>>
#define vsi vector<string>
#define all(n) n.begin(),n.end()
#define forn(i,a,b) for(i=a;i<b;i++)
ll mul(ll x,ll y){  return (x*y)%mod;}
ll power(ll x, ll y) {ll res = 1; x %= mod;
 while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}
ll fact(ll n) {ll res = 1; for (ll i = 2; i <= n; i++) res = mul(res , i); return res; } 
ll nCr(ll n, ll r) { return mul(fact(n),mod_inv(mul(fact(r),fact(n - r))));} 

 
int main() {
  fast;
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  ll t=1;
  // cin>>t;
  while(t--){
  	ll n,m;
  	cin>>n>>m;
  	ll a[n],i;
  	scan(a,n);
  	ll x=0,y=n;
  	for(i=0;i<n;i++){
  		if(a[i]){
  			x++;
  		}
  	}
  	ll c,d;
  	while(m--){
  		cin>>c>>d;
  		if(c==1){
  			if(a[d-1]==1){
  				x--;

  			}else{
  				x++;
  			}
  			a[d-1]=1-a[d-1];
  			

  		}else{
  			// cout<<x<<" "<<d<<" ";
  			if(x>=d){
  				cout<<1<<endl;
  			}else cout<<0<<endl;
  		}
  	}



  	
  }
return 0;    
 }  