#include <fstream>
#include<algorithm>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int tb[10000*4+100], x, n, m, a, b, i, r, u;
void update(int nod, int st, int dr, int poz, int val)
{
if (st==dr) tb[nod]=val;
else
{
int mij=(st+dr)/2;
if (mij>=poz) update(nod*2, st, mij, poz, val);
else update(nod*2+1, mij+1, dr, poz, val);
tb[nod]=max(tb[nod*2], tb[nod*2+1]);
}
}
int query(int nod, int st, int dr, int a, int b)
{
if (a==st && b==dr)
return tb[nod];
int m=(st+dr)/2;
if (b<=m)
return query(2*nod,st,m,a,b);
if (a>=m+1)
return query(2*nod+1,m+1,dr,a,b);
return
max(query(2*nod,st,m,a,m),query(2*nod+1,m+1,dr,m+1,b));
}
int main()
{
f>>n>>m;
for (i=1; i<=n; ++i) {f>>x; update(1, 1, n, i,x);}
for (i=1; i<=m; ++i)
{
f>>u>>a>>b;
if (u==0)
{
r=0;
g<<query(1, 1, n, a, b)<<'\n';
}
else update(1,1,n,a,b);
}
return 0;
}