#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
using ll = long long;
const int N = 2e6 + 15;
int main(){
	int tc;
	tc = 1;
	while(tc--) {
		int n, q, t, x, k;
		cin >> n >> q;
		vector<int> a(n);
		int oneCount = 0;
		for(int i = 0; i < n; ++i) {
			cin >> a[i];
			if(a[i]) oneCount++;
		}
		while(q--) {
			cin >> t;
			if(t == 1) {
				cin >> x;
				x--;
				if(a[x] == 1) oneCount--;
				else oneCount++;
				a[x] = 1 - a[x];
			}else {
				cin >> k;
				if(k <= oneCount) cout << "1\n";
				else cout << "0\n";
			}
		}
	}
	return 0;
}
