#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
const int inf = (1<<30);
int n,q,a[400005];
bool ok;
void update(int nod,int st,int dr,int poz,int nr)
{
if(st==dr) a[nod]=nr;
else {
int mij=(st+dr)/2;
if(poz<=mij) update(2*nod,st,mij,poz,nr);
else update(2*nod+1,mij+1,dr,poz,nr);
a[nod]=max(a[2*nod],a[2*nod+1]);
}
}
int query(int nod,int st,int dr,int x,int y)
{
if(x<=st&&y>=dr) return a[nod];
else {
int mij=(st+dr)/2,mx_st=-inf,mx_dr=-inf;
if(x<=mij) mx_st = query(2*nod ,st,mij,x,y);
if(y>mij) mx_dr = query(2*nod+1,mij+1,dr,x,y);
return max(mx_st,mx_dr);
}
}
int main()
{
int b,c,k;
fin>>n>>q;
for(int i=1;i<=n;i++)
{
fin>>k;
update(1,1,n,i,k);
}
for(int i=1;i<=q;i++)
{
fin>>ok>>b>>c;
if(ok) {
update(1,1,n,b,c);
}
else {
fout<<query(1,1,n,b,c)<<'\n';
}
}
return 0;
}