#include <bits/stdc++.h>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int a[1000005],n,m,maxim;
void cauta(int start, int stop, int prima, int doi, int poz)
{
if(prima <= start && doi >=stop)
{
maxim = max(maxim, a[poz]);
return;
}
if(start!=stop){
int mid = start + (stop-start)/2;
if(prima <=mid) cauta(start,mid,prima,doi,2*poz);
if(doi>mid) cauta(mid+1,stop,prima,doi,2*poz+1);
}
}
void inlocuieste(int start, int stop, int el, int val, int poz)
{
if(start == stop )
{
a[poz]=val;
return;
}
if(start!=stop){
int mid = (start+stop)/2;
if(el<=mid)
inlocuieste(start,mid,el,val,2*poz);
else
inlocuieste(mid+1,stop,el,val,2*poz+1);
a[poz]=max(a[2*poz],a[2*poz+1]);
}
}
int main()
{
f>>n>>m;
for(int i=1;i<=n;++i)
{
int w;
f>>w;
inlocuieste(1,n,i,w,1);
}
for(int i=1;i<=m;++i)
{
int x,y,z;
f>>x>>y>>z;
if(x==0)
{
maxim =0;
cauta(1,n,y,z,1);
g<<maxim<<'\n';
}
else
{
inlocuieste(1,n,y,z,1);
}
}
return 0;
}