#include <iostream>
#include <fstream>
#define Nmax 100010
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int aint[3*Nmax], v[Nmax], a, b;
void update(int st, int dr, int pos, int nod)
{
if(st==dr)
{
aint[nod]=v[pos];
}
else
{
int mij=(st+dr)/2;
if(pos<=mij)
{
update(st, mij, pos, 2*nod);
}
else
{
update(mij+1, dr, pos, 2*nod+1);
}
aint[nod]=max(aint[2*nod], aint[2*nod+1]);
}
}
int q(int st, int dr, int p1, int p2, int nod)
{
if(st==1 && dr==p2)
{
return aint[nod];
}
else
{
int mij= (st+dr)/2;
if(p2<=mij)
{
return q(st, mij, p1, p2, 2*nod);
}
else if(p1>mij)
{
return q(mij+1, dr, p1, p2, 2*nod+1);
}
else
{
return max(q(st, mij, p1, mij, 2*nod), q(mij+1, dr, mij+1, p2, 2*nod+1));
}
}
}
int main()
{
fin>>a>>b;
for(int i=1; i<=a; ++i)
{
fin>>v[i];
update(1, a, i ,1);
}
for(int j=1; j<=b; ++j)
{
int p, m, n;
fin>>p>>m>>n;
if(p==1)
{
v[m]=n;
update(1, a, m, 1);
}
else
{
fout<<q(1, a, m, n, 1)<<"\n";
}
}
}