#include <iostream>
#include <climits>
#include <fstream>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int valori[100100],v[200000],n,i,j,m,stc,drc,cpoz,cnr,cerinta;
void init(int valori[],int v[],int st,int dr,int poz)
{
if(st==dr)
v[poz]=valori[st];
else
{
int m=(st+dr)/2;
init(valori,v,st,m,2*poz);
init(valori,v,m+1,dr,2*poz+1);
v[poz]=max(v[2*poz],v[2*poz+1]);
}
}
int caut(int v[],int st,int dr,int stc,int drc,int poz)
{
if(stc<=st&&drc>=dr)
return v[poz];
else if(stc>dr||drc<st)
return INT_MIN;
else
{
int m=(st+dr)/2;
return max(caut(v,st,m,stc,drc,2*poz),caut(v,m+1,dr,stc,drc,2*poz+1));
}
}
void update(int v[],int st,int dr,int cpoz,int cnr,int poz)
{
if(st==dr)
v[poz]=cnr;
else
{
int m=(st+dr)/2;
if(cpoz>m)
update(v,m+1,dr,cpoz,cnr,2*poz+1);
else
update(v,st,m,cpoz,cnr,2*poz);
v[poz]=max(v[2*poz],v[2*poz+1]);
}
}
int main()
{
f>>n>>m;
for(i=1;i<=n;i++)
f>>valori[i];
init(valori,v,1,n,1);
for(i=1;i<=m;i++)
{
f>>cerinta;
if(cerinta==0)
{
f>>stc>>drc;
g<<caut(v,1,n,stc,drc,1)<<'\n';
}
else
{
f>>cpoz>>cnr;
update(v, 1, n, cpoz, cnr, 1);
}
}
return 0;
}