#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define f(i,l,n) for(int i=l;i<n;i++) 
#define E "\n"
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define vi(typ) vector<typ>

const ll Mod=1e9+7;


ll solve()
{
  ll n,q;
  cin >> n >> q;
  vector<ll> a(n+1);

  f(i,1,n+1) cin >> a[i];

  ll one=0;
  f(i,1,n+1) one+=a[i];

  while(q--)
  {
    ll typ;
    cin >> typ;
    if(typ==1)
    {
      ll x;
      cin >> x;
      if(a[x]==1) a[x]=0,one--;
      else a[x]=1,one++;
    }
    else
    {
      ll k;
      cin >> k;
      if(k<=one) cout<<1<<E;
      else cout<<"0\n";
    }
  }

  return 0;  
}


int main()
{

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