#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
typedef long long ll;
const double pi = acos(-1.0);
const int mod = (1 ? 1000000007 : 998244353);
const int inf = (1 ? 0x3f3f3f3f : 0x7fffffff);
const int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
const ll INF = (1 ? 0x3f3f3f3f3f3f3f3f : 0x7fffffffffffffff);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll poww(ll a, ll b) { ll s = 1; while (b) { if (b & 1)s = (s * a) % mod; a = (a * a) % mod; b >>= 1; }return s % mod; }
/*----------------------------------------------------------------------------------------------------------------------*/

const int N = 1e6 + 11;
ll n,m;
int z[N];


void solve()
{
	cin>>n>>m;
	int sum=0;
	for(int i=1;i<=n;i++)cin>>z[i];
	for(int i=1;i<=n;i++)
	{
		if(z[i]==1)sum++;
	}
	int l,r;
	while(m--)
	{
		cin>>l>>r;
		if(l==1)
		{
			if(z[r]==0)
			{
				z[r]=1;sum++;
			}
			else
			{
				z[r]=0;sum--;
			}
		}
		else
		{
			if(sum>=r)cout<<1<<endl;
			else cout<<0<<endl;
		}
	}
	
}


/*----------------------------------------------------------------------------------------------------------------------*/
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    ll T = 1;
   // cin >> T;
    while (T--)solve();
    return 0;
}
