#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef int64_t ll; 
#define int ll
#define endl '\n'
#define FOR(i,j,n)   for(int i=j;i<n;i++)
#define print(a)     cout<<a<<" "
#define vec          vector<int>
#define pb           push_back    
#define pii          pair<int,int>
#define mp           make_pair
#define f            first
#define s            second
#define all(v)       v.begin(),v.end()
#define mem(a,b)     memset(a,b,sizeof(a))
#define inf          INT_MAX
const int mod=1e9+7;
const int N=5e5+5;

void solve()
{
    //cout<<"Jai Shree Ram";
     int n,q;
     cin >>n>>q;
    int one = 0;
    int a[n];
    for(int i=0;i<n;i++)
    {
        int y;
        cin >>a[i];
        if(a[i] == 1)
         one++;
    }
    while(q--)
    {
        int t;
        cin >>t;
        if(t== 1)
        {
          int x;
          cin >>x;
          x--;
          if(a[x] == 1)
         {
             one--;
             a[x]=0;
         }
         else
         {
             one++;
             a[x]=1;
         }
        }
        if(t==2)
        {
            int k;
            cin >>k;
            if(one >= k)
             cout<<1<<endl;
            else 
             cout<<0<<endl; 
        }
    }

}

int32_t main()
{
     IOS
     int t=1;
     //cin>>t;
     while(t--)
     {
         //cout<<"Case #"<<T++<<": ";
         solve(); 
        // cout<<endl;
     }
     return 0;
}
