#include <bits/stdc++.h>
using namespace std;
int a[100001];
int seg[400004];
void build(int l, int r, int nod){
if(l == r) seg[nod] = a[l];
else{
int m = (l+r)/2;
build(l,m,2*nod);
build(m+1,r,2*nod+1);
seg[nod] = max(seg[2*nod],seg[2*nod+1]);
}
}
void upd(int l, int r, int nod, int point){
if(l == r && r == point) seg[nod] = a[l];
else{
int m = (l+r)/2;
if(l <= point && point <= m) upd(l,m,2*nod,point);
else upd(m+1,r,2*nod+1,point);
seg[nod] = max(seg[2*nod],seg[2*nod+1]);
}
}
int query(int l, int r, int tl, int tr, int nod){
if(tl <= l && r <= tr) return seg[nod];
else if(l > tr || r < tl) return -1;
else {
int m = (l+r)/2;
return max(query(l,m,tl,tr,2*nod),query(m+1,r,tl,tr,2*nod+1));
}
}
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
int n,m;
cin >> n >> m;
for(int i = 1;i<=n;i++){
cin >> a[i];
}
build(1,n,1);
while(m--){
int x,y,z;
cin >> x >> y >> z;
if(x == 0){
cout << query(1,n,y,z,1)<<"\n";
}
else {
a[y] = z;
upd(1,n,1,y);
}
}
return 0;
}