#include <bits/stdc++.h>

#define INF (ll)1e18
#define EPS 1e-4
#define pb push_back
#define pause system("pause")
#define exit exit(0)
#define endl '\n'

using namespace std;
using ull = unsigned long long;
using ll = long long;

typedef pair<int, int> pii;
const int N = 200005, MOD = 1e9 + 7;

int t, n, q, a[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	
	t = 1;
	while (t--) {
		cin >> n >> q;
		vector<int> cnt(2);
		for (int i = 1; i <= n; ++i) {
			cin >> a[i];
			++cnt[a[i]];
		}

		int tt, x;
		while (q--) {
			cin >> tt >> x;
			if (tt == 1) {
				--cnt[a[x]], a[x] ^= 1, ++cnt[a[x]];
			} else {
				cout << (int)(x <= cnt[1]) << endl;
			}
		}
	}
	//pause;
	return 0;
}