#include <bits/stdc++.h>
typedef double          D;
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define ff              first
#define ss              second
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define PI              2.0*acos(0.0)
#define pii             pair<int,int>
#define pll             pair<long long,long long>
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define boost           ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define sss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)
using namespace std;

/*
int bs(int l,int r,int n)
{
    int mid,res=inf;

    while(l<=r)
    {
        mid=l+(r-l)/2;

        if(check(mid,n))
        {
            r=mid-1;
            res=min(res,mid);
        }
        else
            l=mid+1;

    }

    return res;
}
*/


//--------------------------code starts here---------------------------------------
int n,q;

int a[100005];



int main()
{
	int t;
	t=1;
	//si(t);
	while(t--)
	{
        sii(n,q);
        
        int cnt1=0,cnt0=0;

        Rep(i,1,n)
        {
            si(a[i]);

            if(a[i])
                cnt1++;
            else
            {
                cnt0++;
            }
            
        }


        while(q--)
        {
            int type,idx;
            si(type);

            if(type==1)
            {
                si(idx);

                a[idx]=1-a[idx];

                if(a[idx]==0)
                {
                    cnt1--;
                    cnt0++;
                }
                else
                {
                    cnt1++;
                    cnt0--;
                }
                
            }
            else
            {
                si(idx);

                if(cnt1>=idx)
                {
                    printf("1\n");
                }
                else
                {
                    printf("0\n");
                }
                
            }
            


        }




	}

	return 0;
}