/* Noob */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf = 1000000000;

bool cmp(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}
void solve() {
	ll n, q;
	cin >>  n >> q;
	int a[n];
	int op = 0 , dp = 0;
	for (int i = 0 ; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0)op++;
		else dp++;
	}

	while (q--) {
		ll x, y;
		cin >> x >> y;
		if (x == 1) {
			if (a[y - 1] == 1)dp--, op++;
			else {
				op--;
				dp++;
			}
			a[y - 1] ^= 1;
		}
		else {
			if (y > dp) {
				cout << 0 << "\n";
			}
			else {
				cout << 1 << "\n";
			}
		}
	}

}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}

}


