#include <bits/stdc++.h>
const int MAX_N = 100005;
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
struct Interval
{
int maxi;
};
int n, v[MAX_N], q, t;
Interval arbint[4*MAX_N];
Interval create(int value)
{
return Interval {
value,
};
}
Interval join(const Interval &left, const Interval &right)
{
return Interval {
max(left.maxi, right.maxi),
};
}
void build(int nod, int st, int dr)
{
if(st==dr)
arbint[nod]=create(v[st]);
else {
int mij=(st+dr)/2;
build(2*nod, st, mij);
build(2*nod+1, mij+1, dr);
arbint[nod]=join(arbint[2*nod], arbint[2*nod+1]);
}
}
void update(int nod, int st, int dr, int poz, int newValue)
{
if(st==dr)
arbint[nod]=create(newValue);
else {
int mij=(st+dr)/2;
if(poz<=mij)
update(2*nod, st, mij, poz, newValue);
else
update(2*nod+1, mij+1, dr, poz, newValue);
arbint[nod]=join(arbint[2*nod], arbint[2*nod+1]);
}
}
Interval query(int nod, int st, int dr, int left, int right)
{
if(st==left && dr==right)
return arbint[nod];
else {
int mij=(st+dr)/2;
if(right<=mij)
return query(2*nod, st, mij, left, right);
else if(mij<left)
return query(2*nod+1, mij+1, dr, left, right);
else
return join(query(2*nod, st, mij, left, mij),
query(2*nod+1, mij+1, dr, mij+1, right));
}
}
int main()
{
int i, b, a, poz, newValue;
fin>>n>>q;
for(i=1; i<=n; i++)
fin>>v[i];
build(1, 1, n);
while(q--) {
fin>>t;
if(t==0) {
fin>>a>>b;
fout<<query(1, 1, n, a, b).maxi<<'\n';
}
else {
fin>>poz>>newValue;
update(1, 1, n, poz, newValue);
}
}
return 0;
}