using namespace std;
#include<iostream>
#include<fstream>
#define oo 0x3f3f3f3f
#define nmax 100005
#define common int m=(l+r)/2,L=2*n,R=L+1
ofstream fout("arbint.out");
int full[nmax*3],H[nmax*3],a[nmax],N,M;
int query(int n,int l,int r,int ql,int qr)
{
if(full[n])
{
return H[n];
}
if(ql<=l && r<=qr)
{
return H[n];
}
common;
int x, sol=-oo;
if(ql<=m)
{
x=query(L,l,m,ql,qr);
sol=max(sol,x);
}
if(qr>=m+1)
{
x=query(R,m+1,r,ql,qr);
sol=max(sol,x);
}
return sol;
}
void update(int n,int l,int r,int ql,int qr,int v)
{
if(ql<=l && r<=qr)
{
H[n]=v;
full[n]=1;
return;
}
common;
if(full[n])
{
full[n]=0;
full[L]=full[R]=1;
H[L]=H[R]=H[n];
}
if(ql<=m)
update(L,l,m,ql,qr,v);
if(qr>=m+1)
update(R,m+1,r,ql,qr,v);
if(H[L]==H[R] && full[L] && full[R])
{
full[n]=1;
}
else full[n]=0;
H[n]=max(H[L],H[R]);
}
void build(int n,int l,int r)
{
if(l==r) {H[n]=a[l]; full[n]=1; return;}
common;
build(L,l,m);
build(R,m+1,r);
if(H[L]==H[R] && full[L] && full[R])
{
full[n]=1;
}
else full[n]=0;
H[n]=max(H[L],H[R]);
}
void cit()
{
ifstream fin("arbint.in");
fin>>N>>M;
int i,op,x,y;
for(i=1;i<=N;i++)
{
fin>>a[i];
}
build(1,1,N);
for(i=1;i<=M;i++)
{
fin>>op>>x>>y;
if(op==0)
{
fout<<query(1,1,N,x,y)<<"\n";
}
else
{
update(1,1,N,x,x,y);
}
}
fin.close();
}
int main()
{
cit();
fout.close();
return 0;
}