#include<bits/stdc++.h>
using namespace std;

#define endl		'\n'
#define w(t)		int t;cin>>t;while(t--)
#define int			long long
#define fr(i,a,b)	for(int i=a;i<=b;i++)
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define pb 			push_back
#define ppb			pop_back
#define mp			make_pair
#define all(x)		x.begin(),x.end()
#define ff			first
#define ss			second
#define pii			pair<int,int>
#define vi			vector<int>
#define vvi			vector<vi>
#define pqi			priority_queue<int>
#define pqd			priority_queue<int,vi,greater<int>>
#define inf			1e18
#define mod			1000000007



int32_t main() {

	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);



	 int n,q;
	 cin>>n>>q;
	 vi a(n);
	 int c0=0,c1=0;
	 for(int &i:a){
	 	cin>>i;
	 	if(i==0)
	 		c0++;
	 	else 
	 		c1++;
	 }

	 rep(i,0,q){
	 	int x,y;
	 	cin>>x>>y;
	 	if(x==1){
	 		if(a[y-1]==0){
	 			a[y-1]=1;
	 			c0--,c1++;
	 		}
	 		else{
	 			a[y-1]=0;
	 			c0++,c1--;
	 		}
	 	}

	 	else{
	 		if(y>c1)
	 			cout<<0<<endl;
	 		else 
	 			cout<<1<<endl;
	 	}

	 }



	

	return 0;
}