#include<cstdio>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<string>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib> 
#include<chrono>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long
//#define double long double
using namespace std;
	typedef long long ll;
	const int maxn=200505;
	const int inf=0x3f3f3f3f;
	int n,m,k,cnt,q;
    int sum[maxn],max_[maxn];
    int a[maxn];
	struct custom_hash {static uint64_t splitmix64(uint64_t x) {x += 0x9e3779b97f4a7c15;x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;x = (x ^ (x >> 27)) * 0x94d049bb133111eb;return x ^ (x >> 31);}size_t operator()(uint64_t x) const {static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();return splitmix64(x + FIXED_RANDOM);}};
	signed main(){
		IOS
		#ifndef ONLINE_JUDGE
		    freopen("D:\\_ACM_code\\IO\\in.txt","r",stdin);
		    freopen("D:\\_ACM_code\\IO\\out.txt","w",stdout);
        #endif
        IOS
        cin>>n>>q;
        for(int i = 1; i <= n; ++i){
            cin>>a[i];
            cnt += a[i];
        }
        while(q--){
            int opt, x;
            cin>>opt>>x;
            if(opt == 1){
                if(a[x]) cnt--;
                else cnt++;
                a[x] = 1 - a[x];
            }
            else{
                if(cnt >= x) puts("1");
                else puts("0");
            }
        }
        return 0;
    }
  		 	    	     		 		 	 						