#include<cstdio>
#include<cstring>
#include<cstdlib>
int t[350000];
int n;
int x,val,y;
int f (int x, int y)
{
return x>y?x:y;
}
void _update (int n, int s, int e)
{
if(s==e){
t[n]=val;
return;
}
int m=(s+e)/2;
//2*n covers s — m
//2*n+2 covers m+1 — e
if(x<=m)//go left
_update (2*n+1, s, m);
else
_update (2*n+2, m+1, e);
t[n]=f (t[2*n+1],t[2*n+2]);
}
void update (int xx, int vval)
{
x=xx;
val=vval;
_update (0, 0, n-1);
}
int _query (int n, int s, int e)
{
if(s>=x&&y>=e)
return t[n];
int m=(s+e)/2;
if(x<=m&&y>m)//x — y cuts both intervals -> go both ways
return f (
_query (2*n+1, s, m),
_query (2*n+2, m+1, e)
);
if(y<=m)//x — y cuts only left interval -> go left
return _query (2*n+1, s, m);
if(x>m)//x — y cuts only right interval -> go right
return _query (2*n+2, m+1, e);
return -424242;
}
int query (int xx,int yy)
{
x=xx;
y=yy;
return _query (0, 0, n-1);
}
int main()
{
freopen ("arbint.in","r",stdin);
freopen ("arbint.out","w",stdout);
int m;
scanf ("%d%d",&n,&m);
for(int i=0;i<n;i++){
int x;
scanf ("%d ",&x);
update (i,x);
}
char buf[100];
while(m--){
int o,a,b;
gets (buf);
o=buf[0]-'0';
char * x=buf+2;
a=atoi (strtok (x, " "));
b=atoi (strtok (NULL, " "));
//scanf ("%d%d%d",&o,&a,&b);
if(o)
update (a-1,b);
else
printf ("%d\n", query (a-1,b-1));
}
return 0;
}