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

using namespace std;

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    int z = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        z += a[i] == 0;
    }
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            int xi;
            cin >> xi;
            xi--;
            if (a[xi] == 0) {
                z--;
            } else {
                z++;
            }
            a[xi] = 1 - a[xi];
        } else {
            int k;
            cin >> k;
            k--;
            if (k < n - z) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }
}
