#include <bits/stdc++.h>
#define MOD 1000000007
// #define int long long
using namespace std;


void solve()
{
	int n, q, t, x, ones = 0, zeroes = 0;
	cin >> n >> q;
	vector<int> arr(n);
	for (int i = 0; i < n; i++) {
		cin >> x;
		arr[i] = x;
		if (x) ones++;
		else zeroes++;
	}
	for (int i = 0; i < q; i++) {
		cin >> t >> x;
		if (t == 1) {
			if (arr[x - 1] == 0) {
				ones++;
				zeroes--;
			}
			else {
				zeroes++;
				ones--;
			}
			arr[x - 1] = 1 - arr[x - 1];
		}
		else {
			if (x > ones) cout << "0\n";
			else cout << "1\n";
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();
	return 0;
}

