#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e6+13;
int sum[maxn<<2];
int sum2[maxn<<2];
int a[maxn];
void up(int x){
	sum[x]=sum[x<<1]+sum[x<<1|1];
}
void modify(int rt,int l,int r,int pos,int op){
	if(l==r){
		if(op) sum2[rt]-=1;
		else sum2[rt]+=1;
		if(sum2[rt]>0) sum[rt]=1;
		else sum[rt]=0;
		return;
	}
	int mid=l+r>>1;
	if(pos<=mid) modify(rt<<1,l,mid,pos,op);
	else modify(rt<<1|1,mid+1,r,pos,op);
	up(rt);
}
int query(int rt,int l,int r){
	if(l==r){
		return l;
	}
	else{
		int mid=l+r>>1;
		if(sum[rt<<1]<mid-l+1){
			return query(rt<<1,l,mid);
		}
		else{
			return query(rt<<1|1,mid+1,r);
		} 
	}
} 
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int ans=1e9;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++){
		if(i<=m) 
		{
			modify(1,0,n,a[i],0);
			if(i==m) ans=min(ans,query(1,0,n));
		}
		else{
			modify(1,0,n,a[i-m],1);
			modify(1,0,n,a[i],0);
			ans=min(ans,query(1,0,n));
		}
	}
	printf("%d",ans);
}
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define ld double
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--) 
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<double>	vd;
typedef vector<bool>	vb;
typedef pair<ll,ll> 	pll;
#define br "\n"
#define ff first
#define ss second
#define gcd __gcd
#define debug(a...) cout<<#a<<": ";for(auto it:a)cout<<it<<" ";cout<<endl;
ll MAX = 1e7 + 1;
#define MAXIM 200005
ll mod = 1e9 + 7;

vll v;
ll n,q;

void add(ll ind,ll val){
    while(ind <= n){
        v[ind] ^= val;
        ind += (ind & (-1*ind));
    }
}

ll sum(ll ind){
    ll x = 0;
    while(ind > 0){
        x ^= v[ind];
        ind -= (ind & (-1*ind));
    }
    return x;
}

void solve(){
    cin >> n >> q;
    v.resize(n + 1);
    rep(i,1,n + 1){ 
        ll x;
        cin >> x;
        add(i,x);
    }
    rep(i,0,q){
        ll t,a,b;
        cin >> t >> a >> b;
        if(t == 1) add(a,b);
        else cout << (sum(b)^sum(a - 1)) << br;
    }
}
 

int main(){ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 
    
	ll t = 1;
    // cin >> t;
    // calc();
	rep(i,0,t){
        // cout << "Case #" << i + 1 << ": ";
        solve();
        // test();
	}
}