#include <fstream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
#define MAX(a,b) (a>b ? a : b)
const int nmax=100000;
int n,v[nmax+5],A[3*nmax+5];
void build(int st,int dr,int poz)
{
if(st==dr)
{
A[poz]=v[st];
return;
}
int med=(st+dr)/2;
build(st,med,2*poz);
build(med+1,dr,2*poz+1);
A[poz]=MAX(A[2*poz],A[2*poz+1]);
}
void update(int cine,int st,int dr,int poz)
{
if(cine<st || dr<cine)
return;
if(st==dr)
{
A[poz]=v[st];
return;
}
int med=(st+dr)/2;
update(cine,st,med,2*poz);
update(cine,med+1,dr,2*poz+1);
A[poz]=MAX(A[2*poz],A[2*poz+1]);
}
int slove(int a,int b,int st,int dr,int poz)
{
if(dr<a || b<st)
return -(1<<30);
if(a<=st && dr<=b)
return A[poz];
int med=(st+dr)/2;
return MAX(slove(a,b,st,med,2*poz),slove(a,b,med+1,dr,2*poz+1));
}
int T;
int main()
{
fin>>n>>T;
for(int i=1;i<=n;i++)
fin>>v[i];
build(1,n,1);
while(T--)
{
int tip,a,b;
fin>>tip>>a>>b;
if(tip==0)
fout<<slove(a,b,1,n,1)<<"\n";
else
{
v[a]=b;
update(a,1,n,1);
}
}
return 0;
}
/**
**/