#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("arbint.in");
ofstream fout ("arbint.out");
const int nmax = 1e5+5;
int arb[nmax<<2], maxx;
void update(int nod, int st, int dr, int poz, int val)
{
if(st==dr)
{
arb[nod]=val;
return;
}
int mij=(st+dr)>>1;
if(poz<=mij) update(nod<<1, st, mij, poz, val);
else update(nod<<1|1, mij+1, dr, poz, val);
arb[nod]=max(arb[nod<<1], arb[nod<<1|1]);
}
void query(int nod, int st, int dr, int inc, int sf)
{
if(inc<=st && dr<=sf)
{
maxx=max(maxx, arb[nod]);
return;
}
int mij=(st+dr)>>1;
if(inc<=mij) query(nod<<1, st, mij, inc, sf);
if(sf > mij) query(nod<<1|1, mij+1, dr, inc, sf);
}
int main()
{
ios_base::sync_with_stdio(false);
int n, q, x, i, op, a, b;
fin >> n >> q;
for(i=1; i<=n; i++)
{
fin >> x;
update(1, 1, n, i, x);
}
for(i=1; i<=q; i++)
{
fin >> op >> a >> b;
if(op==1) update(1, 1, n, a, b);
else
{
maxx=-1;
query(1, 1, n, a, b);
fout << maxx << "\n";
}
}
fin.close();
fout.close();
return 0;
}