#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define mod 1000000007

vector<ll> pr;
void sieve(){
    const ll k=1e7;
 vector<bool> a(k,true);
 
 for(ll i=2;i*i<k;i++){
  if(a[i]){
      for(ll j=i*i;j<k;j+=i)
      a[j]=false;
  }
 }
 for(ll i=2;i<k;i++){
     if(a[i])
     pr.pb(i);
 }
}

ll kmp(string s){
 ll sz=(ll)s.size();
 vector<ll> lps(sz,0);
 for(ll i=1;i<sz;i++){
  ll pred=lps[i-1];
  while(pred>0 && s[i]!=s[pred]){
   pred=lps[pred-1];
  }
  lps[i]=pred+(s[i]==s[pred]?1:0);
 }
 return lps[sz-1];
}
bool isp(ll n){
 for(ll i=2;i*i<=n;i++){
  if(n%i==0)
  return false;
 }
 return true;
}
long long power(long long a, long long n){
    if(n==0)
    return 1ll;
    if(n==1)
    return a;
    long long p=power(a,n>>1)%mod;
    p=p*p%mod;
    if(n%2!=0)
    p*=a%mod;
    p%=mod;
    return p;
}


void solve(){
  ll n,q;
  cin>>n>>q;
  
  ll z=0;
  ll o=0;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
   cin>>a[i];
   if(a[i])
    o++;
   else
    z++;
  }
  
  while(q--){
    ll t,x;
    cin>>t>>x;
    if(t==1){
      x--;
      if(a[x]){
       o--;
       z++;
      }
      else{
        o++;
        z--;
      }
      a[x]=1-a[x];
    }
    else{
      if(x<=o)
      cout<<1<<endl;
      else
      cout<<0<<endl;
    }
  }
  
  
}

int main(){
 FAST
 ll t=1;
 //cin>>t;
 while(t--){
 solve();
 }
return 0;
}

 