#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define sz size()
using namespace std;
/*const long long mod = 998244353;
long long fct[200005],invfct[200005],inv[200005];
long long put2[200005];
long long lgput (long long a, long long exp)
{
long long rz=1;
while(exp)
if(exp&1)
exp^=1,rz=rz*1LL*a%mod;
else
exp>>=1,a=a*1LL*a%mod;
return rz;
}
long long cmb (long long n, long long k)
{
if(n<k || k<0 || n<0)
return 0;
return fct[n]*1LL*invfct[k]%mod*1LL*invfct[n-k]%mod;
}
void init ()
{
inv[1]=fct[0]=fct[1]=invfct[0]=invfct[1]=put2[0]=1,put2[1]=2;
for(long long i=2;i<=200000;++i)
put2[i]=put2[i-1]*2LL%mod,inv[i]=(mod-mod/i)*1LL*inv[mod%i]%mod,fct[i]=i*1LL*fct[i-1]%mod,invfct[i]=inv[i]*1LL*invfct[i-1]%mod;
}
long long v[200005];*/
//long long
const int inf=1<<30;
int v[100005],t[400005];
void update(int p,int l,int r,int poz,int val)
{
if(l==r)
{
t[p]=val;
return;
}
int m=(l+r)/2;
if(poz<=m)
update(2*p,l,m,poz,val);
else
update(2*p+1,m+1,r,poz,val);
t[p]=max(t[2*p],t[2*p+1]);
}
int query(int p,int l,int r,int a,int b)
{
if(a<=l && r<=b)
return t[p];
if(l>b || r<a)
return 0;
int m=(l+r)/2,rezl=0,rezr=0;
if(a<=m)
rezl=query(2*p,l,m,a,b);
if(m<b)
rezr=query(2*p+1,m+1,r,a,b);
return max(rezl,rezr);
}
void solve()
{
ifstream cin("arbint.in");
ofstream cout("arbint.out");
int n,q;
cin>>n>>q;
for(int i=1;i<=n;i++)
{
cin>>v[i];
update(1,1,n,i,v[i]);
}
while(q--)
{
bool tip;
int a,b;
cin>>tip>>a>>b;
if(tip)
update(1,1,n,a,b);
else
cout<<query(1,1,n,a,b)<<"\n";
}
}
int main()
{
solve();
return 0;
}