#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int i, t, x, ones=0;
    vector<int> result;
    
    //Input
    int n, q;
    cin>>n>>q;
    int a[n];
    for(i=0;i<n; i++)
    {
        cin>>a[i];
        if(a[i]==1)
            ones++;
    }
    

    for(i=0; i<q;i++)
    {

        cin>>t;
        if(t==1)
        {
            cin>>x;
            a[x-1]=1-a[x-1];
            if(a[x-1]==1)
                ones++;
            else
                ones--;
        }
        
        else
        {
            cin>>x;
            if(ones>=x)
                result.push_back(1);
            else
                result.push_back(0);
        }
    }
    

    for(int x: result)
        cout<<x<<"\n";
    return 0;
}