/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <fstream>
#include <vector>
using namespace std;
ifstream cin("arbint.in");
ofstream cout("arbint.out");
int n,m,x;
vector<int> A;
void Update(int st,int dr,int poz,int val,int nod)
{
if(st==dr)
{
A[nod]=val;
return;
}
int mij=st+(dr-st)/2;
if(poz<=mij)
Update(st,mij,poz,val,2*nod);
else
Update(mij+1,dr,poz,val,2*nod+1);
A[nod]=max(A[2*nod],A[2*nod+1]);
}
int Compute(int st,int dr,int a,int b,int nod)
{
if(b<st || dr<a)
return -1;
if(st>=a && dr<=b)
return A[nod];
int mij=st+(dr-st)/2;
return max(Compute(st,mij,a,b,2*nod),Compute(mij+1,dr,a,b,2*nod+1));
}
int main()
{
cin>>n>>m;
A.resize(2*n);
for(int i=1;i<=n;i++)
{
cin>>x;
Update(1,n,i,x,1);
}
for(int i=1;i<=m;i++)
{
bool ok;
int a,b;
cin>>ok>>a>>b;
if(ok==1)
Update(1,n,a,b,1);
else
cout<<Compute(1,n,a,b,1)<<'\n';
}
return 0;
}