/******************************************************************************
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>
#include <cmath>
using namespace std;
ifstream cin("arbint.in");
ofstream cout("arbint.out");
int n,m,x;
vector<int> A;
void update(int nod,int st,int dr,int poz,int a)
{
if(st==dr)
A[nod]=a;
else
{
int mij=st+(dr-st)/2;
if(poz<=mij)
update(2*nod,st,mij,poz,a);
else
update(2*nod+1,mij+1,dr,poz,a);
A[nod]=max(A[2*nod],A[2*nod+1]);
}
}
int query(int st,int dr,int a,int b,int nod)
{
if(dr<a || b<st)
return -1;
else
if(a<=st && dr<=b)
return A[nod];
else
{
int mij=st+(dr-st)/2;
return max(query(st,mij,a,b,2*nod),query(mij+1,dr,a,b,2*nod+1));
}
}
int t,a,b;
int main()
{
cin>>n>>m;
A.resize(4*n+1);
for(int i=1;i<=n;i++)
{
cin>>x;
update(1,1,n,i,x);
}
for(int i=0;i<m;i++)
{
cin>>t;
cin>>a>>b;
switch(t)
{
case 0:
{
cout<<query(1,n,a,b,1)<<'\n';
break;
}
case 1:
{
update(1,1,n,a,b);
}
}
}
return 0;
}