#include <iostream>
#include <fstream>
#include <cstdio>
#define max(a,b) ( (a) > (b) ? a : b)
using namespace std;
// Make NMax > 2^k > 2*n -1
const int NMax = 500004;
int V[NMax];
int n,m;
//Nod is Index of Vector
// 1
// 2 3
// 4 5 6 7
void update(int i, int x, int st, int dr, int nod)
{
int m = (st+dr)/2;
if(st!=dr)
{
if(i<=m)
update(i,x,st,m,2*nod);
else
update(i,x,m+1,dr,2*nod+1);
}
else
{
V[nod]=x;
return;
}
V[nod]=max(V[nod *2],V[nod * 2 +1]);
}
int query(int a, int b, int st, int dr, int nod)
{
int max1,max2,m;
m=(st+dr)/2;
if( a <= st && b>=dr )
return V[nod];
if( a <= m )
max1= query(a,b,st,m,2*nod);
if( b>m)
max2= query(a,b,m+1,dr,2*nod +1);
return max(max1,max2);
}
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
scanf("%d %d",&n, &m);
int nr,i,t,a,b;
for(i=1; i<=n ; i++)
{
scanf("%d",&nr);
update(i,nr,1,n,1);
}
for(i=1; i<=m ;i++)
{
scanf("%d %d %d",&t,&a,&b);
if(t==0)
{
printf("%d\n",query(a,b,1,n,1));
}
else
update(a,b,1,n,1);
}
}