var a:array[1..262143] of longint;
n,m,i,op,x,y,maxim,k:longint;
s:string;
procedure inlocuieste(nod,st,dr:longint);
var mij:longint;
begin
if st>=dr then begin a[nod]:=y; exit; end
else begin
mij:=trunc((st+dr)/2);
if x<=mij then
inlocuieste(nod*2,st,mij) else
inlocuieste(nod*2+1,mij+1,dr);
if a[nod*2]>a[nod*2+1] then
a[nod]:=a[nod*2] else
a[nod]:=a[nod*2+1];
end;
end;
procedure max(nod,st,dr,x,y:longint);
var mij:longint;
begin
if (x<=st) and (y>=dr) then begin
if maxim<a[nod] then maxim:=a[nod]; exit; end
else begin
mij:=trunc((st+dr)/2);
if x<=mij then max(nod*2,st,mij,x,y);
if y>mij then max(nod*2+1,mij+1,dr,x,y);
end;
end;
begin
assign(input,'arbint.in');
reset(input);
readln(n,m);
for x:=1 to n do begin
read(y);
inlocuieste(1,1,n);
end;
assign(output,'arbint.out');
rewrite(output);
for i:=1 to m do begin
read(op,x,y);
if op=1 then begin
inlocuieste(1,1,n);
end else begin
maxim:=0;
max(1,1,n,x,y);
writeln(maxim);
end;
end;
close(output);
end.