#include<cstdio>
#include<vector>
#include<bitset>
using namespace std;
#define pb push_back
#define NM 100001
#define maxim(a,b) (a<b)?(b):(a)
int arb[1<<17],N,M,x,y,v[NM];
void build(int nod, int l, int r)
{
if (l==r)
{
arb[nod]=v[l];
return;
}
int m=(r+l)>>1;
build(nod<<1,l,m);
build((nod<<1)+1,m+1,r);
arb[nod]=maxim(arb[nod<<1],arb[(nod<<1)+1]);
}
int maxxim(int nod,int l, int r, int x, int y)
{
if (x<=l && r<=y)
return arb[nod];
int m=(l+r)>>1,m1=0,m2=0;
if (x<=m)
m1=maxxim(nod<<1,l,m,x,y);
if (m<y)
m2=maxxim((nod<<1)+1,m+1,r,x,y);
return maxim(m1,m2);
}
void update(int nod, int l, int r, int poz, int val)
{
if (l==r)
{
arb[nod]=val;
return;
}
int m=(l+r)>>1;
if (poz<=m)
update(nod<<1,l,m,poz,val);
else
update((nod<<1)+1,m+1,r,poz,val);
arb[nod]=maxim(arb[nod<<1],arb[(nod<<1)+1]);
}
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
scanf("%d%d",&N,&M);
for (int i=1; i<=N; ++i)
scanf("%d",&v[i]);
build(1,1,N);
while (M--)
{
int op;
scanf("%d%d%d",&op,&x,&y);
if (op==0)
printf("%d\n",maxxim(1,1,N,x,y));
else
update(1,1,N,x,y);
}
return 0;
}