#include<iostream>
#define ll long long
using namespace std;
ll n,m,a[1005],op,x,y,maxn,M;
int ZhongShu(int A, int b){
int ed[1005];
for(int i = A; i <= b; i++){
int o = a[i];
ed[o]++;
}
for(int i = 1; i <= maxn; i++){
if(ed[i] > M) M = a[ed[i]];
}
return M;
}
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> a[i];
if(a[i] > maxn) maxn = a[i];
}
for(int i = 1; i <= m; i++){
cin >> op;
if(op == 0){
cin >> x >> y;
cout << ZhongShu(x, y) << endl;
} else if(op == 1){
cin >> x >> y;
a[x] = y;
} else {
continue;
}
}
return 0;
}