#include <iostream>
#include <fstream>
using namespace std;
int v[100005];
int aint[400005];
int join (int a, int b)
{
return max(a, b);
}
void build(int l, int r, int cr)
{
if (l==r){aint[cr]=v[l]; return;}
int mid=(l+r)/2;
build (l, mid, 2*cr), build (mid+1, r, 2*cr+1);
aint[cr]=join(aint[2*cr], aint[2*cr+1]);
return;
}
void update(int l, int r, int val, int poz, int cr)
{
if (l==r)
{
aint[cr]=val;
return;
}
int mid=(l+r)/2;
if (mid<poz)
update(mid+1, r, val, poz, 2*cr+1);
else
update(l, mid, val, poz, 2*cr);
aint[cr]=join(aint[2*cr], aint[2*cr+1]);
}
int quewy(int l, int r, int ql, int qr, int cr)
{
if (ql<=l&&r<=qr)
return aint[cr];
int mid=(l+r)/2;
if (mid<ql)
return quewy(mid+1, r, ql, qr, 2*cr+1);
else if (qr<=mid)
return quewy(l, mid, ql, qr, 2*cr);
else
return join(quewy(l, mid, ql, qr, 2*cr), quewy(mid+1, r, ql, qr, 2*cr+1));
}
int main()
{
ifstream cin ("arbint.in");
ofstream cout ("arbint.out");
int n, m, gender, a, b;
cin>>n>>m;
for (int i=1; i<=n; i++)
{
cin>>v[i];
}
build (1, n, 1);
for (int i=1; i<=m; i++)
{
cin>>gender>>a>>b;
if (gender)
{
update(1, n, b, a, 1);
}
else
{
cout<<quewy(1, n, a, b, 1)<<'\n';
}
}
}