#include<iostream>
#include<fstream>
using namespace std;
#define MAX 100001
unsigned int max(unsigned int a, unsigned int b){
if(a>b) return a;
return b;
}
unsigned int constr(unsigned int node, unsigned int heap[],unsigned int set[],unsigned int left, unsigned int right){
if(left==right) { heap[node]=set[left]; return set[left];}
else{
unsigned int mid=(left+right)/2;
heap[node]=max(constr(2*node,heap,set,left,mid), constr(2*node+1,heap,set,mid+1,right));
return heap[node];
}
}
unsigned int maxSeq(unsigned int node, unsigned int left, unsigned int right, unsigned int heap[], unsigned int a, unsigned int b){
if(a<=left && b>=right) return heap[node];
else{
unsigned int x=0,y=0;
unsigned int mid=(right+left)/2;
if(a<=mid) x=maxSeq(2*node,left,mid,heap,a,b);
if(b>mid) y=maxSeq(2*node+1,mid+1,right,heap,a,b);
return max(x,y);
}
}
void update(unsigned int node, unsigned int with, unsigned int poz, unsigned int heap[], unsigned int left, unsigned int right){
if(left==right) heap[node]=with;
else{
unsigned int mid=(right+left)/2;
if(poz<=mid) update(2*node,with,poz,heap,left,mid);
else update(2*node+1,with,poz,heap,mid+1,right);
heap[node]=max(heap[2*node],heap[2*node+1]);
}
}
int main(){
ifstream in("arbint.in"); ofstream out("arbint.out");
unsigned int n,m,op,a,b;
in>>n>>m;
unsigned int set[n+1],i,heap[MAX];
for(i=1;i<=n;i++) in>>set[i];
constr(1,heap,set,1,n);
for(i=1;i<=m;i++){
in>>op>>a>>b;
if(op==1) update(1,b,a,heap,1,n);
else out<<maxSeq(1,1,n,heap,a,b)<<'\n';
}
return 0;
}