#include <bits/stdc++.h>

using namespace std;


#define     mod             (int)1e9+7
#define     MOD             998244353
#define     ll              long long
#define     mp              make_pair
#define     deb(x)          cout<< x << endl
#define     F               first
#define     S               second
#define     pb              push_back
#define     pf              emplace_front
#define     all(p)          p.begin(), p.end()
#define     rep(i,a,b)      for( i=a;i<b;++i)
#define     repr(i,a,b)     for( i=a;i>=b;i--)
#define     up              upper_bound
#define     lb              lower_bound
#define     t()             int test;cin>>test;while(test--)
#define     setbits(x)      __builtin_popcountll(x)
#define     si              set<int>
#define     que_max         priority_queue <int>
#define     que_min         priority_queue <int, vi, greater<int> >
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n"
#define isOn(S, j)                   (S & (1 << j))
#define setBit(S, j)                 (S |= (1 << j))
#define clearBit(S, j)               (S &= ~(1 << j))
#define toggleBit(S, j)              (S ^= (1 << j))
#define lowBit(S)                    (S & (-S))
#define setAll(S, n)                 (S = (1 << n) - 1)
#define modulo(S, N)                 ((S) & (N - 1))
#define isPowerOfTwo(S)              (!(S & (S - 1)))
#define nearestPowerOfTwo(S)         ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S)            ((S) & (S - 1))
#define turnOnLastZero(S)            ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))

typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;
  //use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
int mpow(int base, int exp);  
void ipgraph(int n, int m);
void dfs(int u, int par);

const int N = 100005, M = 100005;
//=======================

vl g[N];
int a[N];

void solve()
{
     ll n, q,i,j;
    cin >> n >> q;
    i=mpow(5,3);
j=mpow(1,3);
vl array(5);
rep(i,0,5)
array[i]=-1;
    int a[n];
    int o = 0, z = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0)
            z++;
        else
            o++;
    }
    while (q--) {
        int t, t2, x, k;
        cin >> t >> t2;
        if (t == 1) {
            x = t2;
            if (a[x - 1] == 0) {
                o++;
                z--;
                a[x - 1] = 1;
            }
            else {
                z++;
                o--;
                a[x - 1] = 0;
            }
        } else if (t == 2) {
            k = t2;
            if (o >= k)
                cout << 1 << "\n";
            else
                cout << 0 << "\n";
        }


    }
}

int main()
{
  IOS;

  // t()
  {
       solve();
  }

}
int mpow(int base, int exp) {
  base %= (mod);
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % (mod);
    base = ((ll)base * base) % (mod);
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
  int i, u, v;
  while(m--){
    cin>>u>>v;
    u--, v--;
    g[u].pb(v);
    g[v].pb(u);
  }
}

void dfs(int u, int par){
  for(int v:g[u]){
    if (v == par) continue;
    dfs(v, u);
  }
}