#include <string>
#include <string.h>
#include <queue>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <set>
#include <map>
#include<stack>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
const int  INF = 0x3f3f3f3f;//无穷大
const int N = 1e5 + 5;
const int mod = 1e3;

inline ll qpow(ll a, ll b, ll MOD = mod) { ll res = 1; a %= MOD; while (b > 0) { if (b & 1)res = res * a % MOD; a = a * a % MOD; b >>= 1; }return res; }
int A[N];
int B[N];

bool cmp(int a, int b) {
	return a > b;
}
int main() {
	int n, q;
	cin >> n >> q;
	int num0 = 0, num1 = 0;
	for (int i = 1; i <= n; i++) {
		cin >> A[i];
		if (A[i] == 0) num0++;
		else num1++;
	}
	while (q--) {
		int a, b;
		cin >> a >> b;
		if (a == 1) {
			if (A[b] == 1) A[b]=0,num0++, num1--;
			else A[b]=1,num1++, num0--;
		}
		//cout << "num0=" << num0 << " " << "num1=" << num1 << endl;
		if (a == 2) {
			if (b > num1) cout << 0 << endl;
			else cout << 1 << endl;
		}
	}
	return 0;
}