var n,m,i,a,b,c:longint;
v:array[1..100000] of longint;
d:array[1..300000] of longint;
function creare(nod,st,dr:longint):longint;
var m,k,p:longint;
begin
if st=dr then begin
creare:=v[st];
d[nod]:=v[st];
end
else begin
m:=(st+dr) div 2;
k:=creare(nod*2, st, m);
p:=creare(nod*2+1, m+1, dr);
if k>p then begin
d[nod]:=k;
creare:=k;
end else begin
creare:=p;
d[nod]:=p;
end;
end;
end;
function interogare(nod,st,dr,a,b:longint):longint;
var m,k,p:longint;
begin
if (a<=st) and (dr<=b) then
interogare:=d[nod]
else begin
m:=(st+dr) div 2;
if a<=m then k:=interogare(nod*2,st,m,a,b);
if b>m then p:=interogare(nod*2+1,m+1,dr,a,b);
if k>p then interogare:=k else interogare:=p;
end;
end;
procedure actualizare(nod,st,dr,a,b:longint);
var m,k:longint;
begin
if (a=st) and (a=dr) then begin
d[nod]:=b;
end else begin
m:=(st+dr) div 2;
if a<=m then begin
actualizare(nod*2,st,m,a,b);
end else begin
actualizare(nod*2+1,m+1,dr,a,b);
end;
if d[nod*2]>d[nod*2+1] then d[nod]:=d[nod*2]
else d[nod]:=d[nod*2+1];
end;
end;
begin
assign(input,'arbint.in');
assign(output,'arbint.out');
reset(input);
rewrite(output);
read(n,m);
for i:=1 to n do read(v[i]);
creare(1,1,n);
// for i:=1 to n*3 do write(d[i], ' ');
for i:=1 to m do begin
read(c,a,b);
if c=0 then
writeln(interogare(1,1,n,a,b))
else begin
v[a]:=b;
actualizare(1,1,n,a,b);
// creare(1,1,n);
end;
end;
end.