#include<bits/stdc++.h> 
using namespace std;
#define lli          long long int
#define pb           push_back
#define ppb          pop_back
#define pf           push_front
#define ppf          pop_front
#define all(x)       (x).begin(),(x).end() 
#define pii          pair<int,int>
#define rep(i,a,b,n)   for(int i=a;i<b;i+=n)
#define uniq(v)      (v).erase(unique(all(v)),(v).end())
#define sz(x)        (int)((x.size()))
#define fr           first
#define sc           second
#define mem1(a)      memset(a,-1,sizeof(a))
#define mem0(a)      memset(a,0,sizeof(a))
#define ppc          __builtin_popcount
#define ppcll        __builtin_popcountll

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n,q,count=0;
    cin>>n>>q;
    vector<int> a(n,0);
    rep(i,0,n,1){
        cin>>a[i];
        count+=a[i];
    }
    rep(i,0,q,1){
        int m,o;
        cin>>m>>o;
        o--;
        if(m==1){
            if(a[o]==1) count--; 
            else count++;
            a[o]=1-a[o];
        }
        else{
            if(count>=o+1){
                cout<<"1"<<endl;
            }
            else{
                cout<<"0"<<endl;
            }
        }
    }
    return 0;
}
