var v:array[1..1036000] of int64;
n,m,i,c,d,poz:longint;
e,maxim:int64;
f,g:text;
function max(x,y:int64):int64;
begin
if x>y then
max:=x
else
max:=y;
end;
procedure int(nod,a,b,lo,hi:longint);
begin
if (lo<=a) and (b<=hi) then
begin
if v[nod]>maxim then
maxim:=v[nod]
end
else
begin
if lo<=a+(b-a) div 2 then
int(nod*2,a,a+(b-a) div 2,lo,hi);
if hi>a+(b-a) div 2 then
int(nod*2+1,a+(b-a) div 2+1,b,lo,hi);
end;
end;
procedure update(nod,a,b:longint;val:int64);
begin
if a=b then
v[nod]:=val
else
begin
if poz<=a+(b-a) div 2 then
update(nod*2,a,a+(b-a) div 2,val)
else
update(nod*2+1,a+(b-a) div 2+1,b,val);
v[nod]:=max(v[nod*2],v[nod*2+1]);
end;
end;
begin
assign(f,'arbint.in');
assign(g,'arbint.out');
reset(f);rewrite(g);
readln(f,n,m);
for i:=1 to n do
begin
read(f,e);
poz:=i;
update(1,1,n,e);
end;
for i:=1 to m do
begin
readln(f,c,d,e);
if c=0 then
begin
maxim:=0;
int(1,1,n,d,e);
writeln(g,maxim);
end
else
begin
poz:=d;
update(1,1,n,e);
end;
end;
close(f);close(g);
end.