#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define P pair
#define V vector
const long long MOD = 1000000007; // 1e9 + 7
long long mod(long long a, long long b) {
return (a % b + b) % b;
}
void file(){
freopen("input.txt.txt","r",stdin);
freopen("output.txt.txt","w",stdout);
}
int maxer(int a,int b,int c){
return max(a,max(b,c));
}
void setio(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
bool issorted(int n,int A[]){
for(int i=0;i<n-1;i++){
if(A[i+1]<A[i])
return false;
}
return true;
}
void dfs(int x,vector<int>graph[],vector<bool>&visited,vector<int>&vp) {
if (visited[x])return;
visited[x] = true;
vp.pb(x);
for (auto u: graph[x])
dfs(u, graph, visited, vp);
}
vector<ll>divisors(ll n){
vector<ll>ans;
for(ll i=1;i*i<=n;i++){
if(i*i==n){
ans.pb(i);
continue;
}
if(n%i==0){
ans.pb(i);
ans.pb(n/i);
}
}
return ans;
}
bool check(ll m,const ll A[],ll k){
return k>=A[m];
}
struct node{
ll max_seg;
ll max_pref;
ll max_suff;
ll sum;
};
struct segtree{
int size;
V<int>sums;
int value(int i){
return sums[i+size];
}
void init(int n){
size=1;
while(size<n)size*=2;
sums.assign(2*size,0LL);
}
void set(int i,int v){
i+=size;
sums[i]=v;
for(i/=2;i>=1;i/=2){
sums[i]=sums[2*i]+sums[2*i+1];
}
}
int result(int k){
int search=1;
while(search<size){
int s1=sums[search*2];
if(s1>=k+1)
search*=2;
else
search=search*2+1;
}
return search-size;
}
};
void solve(){
int n,q;
cin>>n>>q;
segtree st;
st.init(n);
for(int i=0;i<n;i++){
int x;
cin>>x;
st.set(i,x);
}
while(q--){
int t;
cin>>t;
if(t==1){
int index;
cin>>index;
if(st.value(index)==1)
st.set(index,0);
else
st.set(index,1);
}
else{
int k;
cin>>k;
cout<<st.result(k)<<endl;
}
}
}
int main(){
//file();
solve();
return 0;
}
I2luY2x1ZGUgPGJpd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PSB0cnVlOwogICAgdnAucGIoeCk7CiAgICBmb3IgKGF1dG8gdTogZ3JhcGhbeF0pCiAgICAgICAgZGZzKHUsIGdyYXBoLCB2aXNpdGVkLCB2cCk7Cn0KdmVjdG9yPGxsPmRpdmlzb3JzKGxsIG4pewogICAgdmVjdG9yPGxsPmFuczsKICAgIGZvcihsbCBpPTE7aSppPD1uO2krKyl7CiAgICAgICAgaWYoaSppPT1uKXsKICAgICAgICAgICAgYW5zLnBiKGkpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYobiVpPT0wKXsKICAgICAgICAgICAgYW5zLnBiKGkpOwogICAgICAgICAgICBhbnMucGIobi9pKTsKICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gYW5zOwp9CmJvb2wgY2hlY2sobGwgbSxjb25zdCBsbCBBW10sbGwgayl7CiAgICByZXR1cm4gaz49QVttXTsKfQpzdHJ1Y3Qgbm9kZXsKICAgIGxsIG1heF9zZWc7CiAgICBsbCBtYXhfcHJlZjsKICAgIGxsIG1heF9zdWZmOwogICAgbGwgc3VtOwp9OwpzdHJ1Y3Qgc2VndHJlZXsKICAgIGludCBzaXplOwogICAgVjxpbnQ+c3VtczsKICAgIGludCB2YWx1ZShpbnQgaSl7CiAgICAgICAgcmV0dXJuIHN1bXNbaStzaXplXTsKICAgIH0KICAgIHZvaWQgaW5pdChpbnQgbil7CiAgICAgICAgc2l6ZT0xOwogICAgICAgIHdoaWxlKHNpemU8bilzaXplKj0yOwogICAgICAgIHN1bXMuYXNzaWduKDIqc2l6ZSwwTEwpOwogICAgfQogICAgdm9pZCBzZXQoaW50IGksaW50IHYpewogICAgICAgIGkrPXNpemU7CiAgICAgICAgc3Vtc1tpXT12OwogICAgICAgIGZvcihpLz0yO2k+PTE7aS89Mil7CiAgICAgICAgICAgIHN1bXNbaV09c3Vtc1syKmldK3N1bXNbMippKzFdOwogICAgICAgIH0KICAgIH0KICAgIGludCByZXN1bHQoaW50IGspewogICAgICAgIGludCBzZWFyY2g9MTsKICAgICAgICB3aGlsZShzZWFyY2g8c2l6ZSl7CiAgICAgICAgICAgIGludCBzMT1zdW1zW3NlYXJjaCoyXTsKICAgICAgICAgICAgaWYoczE+PWsrMSkKICAgICAgICAgICAgICAgIHNlYXJjaCo9MjsKICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgc2VhcmNoPXNlYXJjaCoyKzE7CiAgICAgICAgfQogICAgICAgIHJldHVybiBzZWFyY2gtc2l6ZTsKICAgIH0KfTsKdm9pZCBzb2x2ZSgpewogaW50IG4scTsKIGNpbj4+bj4+cTsKIHNlZ3RyZWUgc3Q7CiBzdC5pbml0KG4pOwogZm9yKGludCBpPTA7aTxuO2krKyl7CiAgICAgaW50IHg7CiAgICAgY2luPj54OwogICAgIHN0LnNldChpLHgpOwogfQogd2hpbGUocS0tKXsKICAgICBpbnQgdDsKICAgICBjaW4+PnQ7CiAgICAgaWYodD09MSl7CiAgICAgICAgIGludCBpbmRleDsKICAgICAgICAgY2luPj5pbmRleDsKICAgICAgICAgaWYoc3QudmFsdWUoaW5kZXgpPT0xKQogICAgICAgICAgICAgc3Quc2V0KGluZGV4LDApOwogICAgICAgICBlbHNlCiAgICAgICAgICAgICBzdC5zZXQoaW5kZXgsMSk7CiAgICAgfQogICAgIGVsc2V7CiAgICAgICAgIGludCBrOwogICAgICAgICBjaW4+Pms7CiAgICAgICAgIGNvdXQ8PHN0LnJlc3VsdChrKTw8ZW5kbDsKICAgICB9CiB9Cn0KCgppbnQgbWFpbigpewogICAvL2ZpbGUoKTsKICAgc29sdmUoKTsKICAgIHJldHVybiAwOwp9