#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f ("arbint.in");
ofstream t ("arbint.out");
int v[300005],n,m,mx;
void arb_update(int nod,int left,int right,int pos,int val)
{
if (left==right)
v[nod]=val;
else
{
int mid=(left+right)/2;
if (pos<=mid)
arb_update(nod*2,left,mid,pos,val);
else
arb_update(nod*2+1,mid+1,right,pos,val);
v[nod]=max(v[nod*2],v[nod*2+1]);
}
}
void arb_query(int nod,int st,int dr,int left,int right)
{
if(left<=st and dr<=right) mx=max(mx,v[nod]);
else
{
int mid=(st+dr)/2;
if(left<=mid) arb_query(nod*2,st,mid,left,right);
if(mid<right) arb_query(nod*2+1,mid+1,dr,left,right);
}
}
void read()
{
int x,tip,a,b;
f>>n>>m;
for (int i=1; i<=n; ++i)
{
f>>x;
arb_update(1,1,n,i,x);
}
for (int i=0; i<m; ++i)
{
f>>tip>>a>>b;
if (tip==0)
{
mx=0;
arb_query(1,1,n,a,b);
t<<mx<<'\n';
}
else arb_update(1,1,n,a,b);
}
}
int main()
{
read();
return 0;
}