#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX = 10e5;
int main()
{
    int a, b, t, x, y, count = 0;
    bool arr[MAX];

    cin >> a >> t;

    for (int i = 0; i < a; i++)
    {
        scanf("%d", &arr[i]);
        count += arr[i];
    }

    while (t--)
    {
        //   cin >> x >> y;
        scanf("%d %d", &x, &y);
        if (x == 1)
        {
            count -= arr[y - 1];
            arr[y - 1] = 1 - arr[y - 1];
            count += arr[y - 1];
        }
        else
            printf("%d\n", count >= y);
    }
}