#include <fstream>
#define DIM 100005
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int N,M;
int A[4*DIM];
int type,a,b;
int maxim;
void build(int nod,int p,int u){
if(p==u){
fin >> A[nod];
return;
}
int m = (p+u)>>1;
build(2*nod,p,m);
build(2*nod+1,m+1,u);
A[nod] = max(A[2*nod],A[2*nod+1]);
}
void update(int nod,int p,int u,int a,int b){
if(p==u && p==a){
A[nod] = b;
return;
}
int m = (p+u)>>1;
if(a<=m)
update(2*nod,p,m,a,b);
else
update(2*nod+1,m+1,u,a,b);
A[nod] = max(A[2*nod],A[2*nod+1]);
}
void query(int nod,int p,int u,int a,int b){
if(p>=a && u<=b){
maxim = max(maxim,A[nod]);
return;
}
int m = (p+u)>>1;
if(a<=m)
query(2*nod,p,m,a,b);
if(b>m)
query(2*nod+1,m+1,u,a,b);
}
int main(){
fin >> N >> M;
build(1,1,N);
while(M--){
fin >> type >> a >> b;
if(type)
update(1,1,N,a,b);
else{
maxim = 0;
query(1,1,N,a,b);
fout << maxim << "\n";
}
}
}