program arobri;
var f,g:text;
n,m,i,max,x,y,nr:longint;
v:array[1..100000] of longint;
bufin,bufout:array[1..65000] of byte;
function maxim (a,b:longint):longint;
begin
if a>b then
maxim:=a
else
maxim:=b;
end;
procedure update (nod,st,dr,poz,val:longint);
var jum:longint;
begin
if st=dr then
begin
v[nod]:=val;
end
else
begin
jum:=(st+dr) div 2;
if poz<=jum then
update (nod*2,st,jum,poz,val)
else
update (nod*2+1,jum+1,dr,poz,val);
v[nod]:=maxim (v[nod*2],v[nod*2+1]);
end;
end;
procedure query (nod,st,dr,a,b:longint);
begin
if (a<=st) and (b>=dr) then
begin
if max<v[nod] then
max:=v[nod];
end
else
begin
if a<=((st+dr) div 2) then query (nod*2,st,(st+dr) div 2,a,b);
if b>(st+dr) div 2 then
query (nod*2+1,(st+dr) div 2+1,dr,a,b);
end;
end;
begin
assign (f,'arbint.in'); reset (f);
assign (g,'arbint.out'); rewrite (g);
settextbuf (f,bufin); settextbuf (g,bufout);
readln (f,n,m);
for i:=1 to n do
begin
read (f,x);
update (1,1,n,i,x);
end;
readln (F);
for i:=1 to m do
begin
readln (f,nr,x,y);
if nr=0 then
begin
max:=0;
query (1,1,n,x,y);
writeln (g,max);
end
else
begin
update (1,1,n,x,y);
end;
end;
close (f); close (g);
end.