#include <iostream>
#include <fstream>
using namespace std;
int V[100005];
int maxim[400005];
int M, N;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int stanga(int i){
return i*2+1;
}
int dreapta(int i){
return i*2+2;
}
void construieste_arbore(int nod, int st, int dr){
int m = (st+dr)/2;
// cout << nod << " " << st << " " << dr << "\n";
if(st == dr)
maxim[nod] = V[st];
else{
construieste_arbore(stanga(nod), st, m);
construieste_arbore(dreapta(nod), m+1, dr);
maxim[nod] = max(maxim[stanga(nod)], maxim[dreapta(nod)]);
}
}
void update_nod(int nod, int st, int dr, int pos, int val ){
int m;
if(st == dr)
maxim[nod] = val;
else{
m = (st + dr)/2;
//maxim[nod] = max(maxim[nod], val);
if(pos <= m)
update_nod(stanga(nod), st, m, pos, val);
else
update_nod(dreapta(nod), m+1, dr, pos, val);
maxim[nod] = max(maxim[stanga(nod)], maxim[dreapta(nod)]);
}
}
bool inclus(int st, int dr, int a, int b){
if( st >= a && dr <= b)
return true;
return false;
}
bool inters(int st, int dr, int a, int b){
if( dr >= a && st <= b)
return true;
return false;
}
int query(int nod, int st, int dr, int a, int b){
int m = (st+dr)/2;
if(inclus(st, dr, a, b))
return maxim[nod];
else {
int p1 = -1, p2 = -1;
if(inters(st, m, a, b))
p1 = query(stanga(nod), st, m, a, b);
if(inters(m+1, dr, a, b))
p2 = query(dreapta(nod), m+1, dr, a, b);
return max(p1, p2);
}
}
void afis_arbore(){
for(int i=0; i<2*N-1; i++)
cout << maxim[i] << " ";
cout << endl;
}
int main()
{
fin >> N >> M;
for(int i=0; i<N; i++){
fin >> V[i];
}
construieste_arbore(0, 0, N-1);
int op, x, y;
for(int i=0; i<M; i++){
fin >> op >> x >> y;
if(op == 0)
fout << query(0, 0, N-1, x-1, y-1) << endl;
else
if(op == 1)
update_nod(0, 0, N-1, x-1, y);
}
return 0;
}