#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ifstream cin("arbint.in");
ofstream cout("arbint.out");
int n;
int tree[400006];
void Update(int node,int from,int to,int pos,int val)
{
if(from==to)
{
tree[node]=val;
return;
}
int m=(from+to)/2;
if(pos<=m)
{
Update(node*2,from,m,pos,val);
}
else
{
Update(node*2+1,m+1,to,pos,val);
}
tree[node]=max(tree[node*2],tree[node*2+1]);
}
int Query(int node,int from,int to,int l,int r)
{
if(l<=from && to<=r)
{
return tree[node];
}
int maxx=0;
int m=(from+to)/2;
if(m>=l)
{
maxx=max(maxx,Query(node*2,from,m,l,r));
}
if(m+1<=r)
{
maxx=max(maxx,Query(node*2+1,m+1,to,l,r));
}
return maxx;
}
int main()
{
int n,q;
cin>>n>>q;
vector<int>v(n);
for(int i=1;i<=n;i++)
{
cin>>v[i];
Update(1,1,n,i,v[i]);
}
int type,a,b;
for(int i=0;i<q;i++)
{
cin>>type>>a>>b;
if(type==1)
{
Update(1,1,n,a,b);
}
else
{
cout<<Query(1,1,n,a,b)<<"\n";
}
}
return 0;
}