#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define pb push_back
#define fr(i,a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<ll,pair<ll,ll>>
#define goog(tno) cout << "Case #" << tno <<": "
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define read(x) int x; cin >> x
 
void init_code(){
    fast_io;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
}

int main(){
	init_code();
	ll n,q;
	cin >> n >> q;
	ll a[n],c[2]={0,0};
	fr(i,0,n){
		cin >> a[i];
		c[a[i]]++;
	}
	fr(i,0,q){
		ll t,k;
		cin >> t >> k;
		if(t == 1){
			if(a[k-1] == 1){
				c[1]--;
				c[0]++;
			}
			else{
				c[0]--;
				c[1]++;
			}
			a[k-1] = 1 - a[k-1];
		}
		else{
			if(k <= c[1]){
				cout << 1 << endl;
			}
			else{
				cout << 0 << endl;
			}
		}
	}
}