#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, q;
	cin >> n >> q;
	vector<int> arr(n+1, 0);
	int zero =0, one = 0;
	for(int i=1; i<=n; ++i){
		cin >> arr[i];
		if(arr[i] == 0) ++zero;
		else ++one;
	}
	int tp, val;
	while(q--){
		cin >> tp >> val;
		if(tp==1){
			if(arr[val] == 0){
				--zero,  ++one;
			}
			else{
				++zero, --one;
			}
			arr[val] = 1-arr[val];
		}
		else{
			if(one >= val) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}
}
