#include <iostream>
#include <cstdio>

using namespace std;
const int M = 1e5 + 7;
int num[M];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    int cnt = 0;
    for(int i = 1; i <= n; i ++)
    {
        scanf("%d", &num[i]);
        if(num[i]) cnt ++;
    }

    while(m --)
    {
        int op, x;
        scanf("%d%d", &op, &x);
        if(op == 1)
        {
            if(num[x] == 1){
                cnt --;
                num[x] = 0;
            }
            else{
                cnt ++;
                num[x] = 1;
            }
        }
        else
        {
            if(x <= cnt)printf("1\n");
            else printf("0\n");
        }
    }

    return 0;
}
