#include <iostream>
#include <fstream>
#define For(i, x, y) for(int i = x; i <= y; ++i)
#define Forr(i, x, y) for(int i = x; i >= y; --i)
using namespace std;
int n, v[400005], m, mij, mx, t, a, b, x ;
void update(int nod, int st, int dr, int p, int val){
if(st == dr) v[nod] = val;
else {
int mij = (st + dr) / 2;
if(p <= mij) update(2 * nod, st, mij, p, val);
else update(2 * nod + 1, mij + 1, dr, p, val);
v[nod] = max(v[2 * nod], v[2 * nod + 1]);
}
}
void query(int nod, int st, int dr, int a, int b){
if(a <= st and dr <= b)
mx = max(v[nod], mx);
else{
int mij = (st + dr) / 2;
if(a <= mij) query(2 * nod, st, mij, a, b);
if(b > mij) query(2 * nod + 1, mij + 1, dr, a, b);
}
}
int main()
{
ifstream fin("arbint.in");
ofstream fout("arbint.out");
fin >> n >> m;
For(i, 1, n){
fin >> x;
update(1, 1, n, i, x);
}
For(i, 1, m){
fin >> t >> a >> b;
if(t == 0){
mx = -1;
query(1, 1, n, a, b);
fout << mx << '\n';
}
else update(1, 1, n, a, b);
}
return 0;
}