#include<cstdio>
#include<vector>
#define Check() if (++pos == 8192) {fread (buff, 1, 8192, stdin); pos = 0;}
#define max(a,b) a>b ? a : b
using namespace std;
int n, m, valMax, pos;
int arb[300001];
char buff[8192];
inline void ReadInt(int &nr){
nr = 0;
while (buff[pos] < '0' || buff[pos] > '9')
Check();
while (buff[pos] >= '0' && buff[pos] <= '9'){
nr = nr * 10 + (buff[pos] - '0');
Check();
}
}
void Update(int nod, int st, int dr, int poz, int val){
if (st == dr) {arb[nod] = val; return;}
int mij = (st + dr) / 2;
if (poz <= mij) Update(2*nod, st, mij, poz, val);
else Update(2*nod + 1, mij + 1, dr, poz, val);
arb[nod] = max(arb[2*nod], arb[2*nod+1]);
}
void Query(int nod, int st, int dr, int &first, int &last){
if (first <= st && dr <= last){
if (valMax < arb[nod]) valMax = arb[nod];
return;
}
int mij = (st + dr) / 2;
if (first <= mij) Query(nod * 2, st, mij, first, last);
if (mij < last) Query(nod * 2 + 1, mij + 1, dr, first, last);
}
int main(){
freopen ("arbint.in", "r", stdin);
freopen ("arbint.out", "w", stdout);
ReadInt(n); ReadInt(m);
int i, tip, a, b;
for (i = 1; i <= n; i++) {
ReadInt(a);
Update(1, 1, n, i, a);
}
for (i = 0; i < m; i++){
ReadInt(tip); ReadInt(a); ReadInt(b);
if (tip == 1) Update(1, 1, n, a, b);
else {
valMax = -1;
Query(1, 1, n, a, b);
printf ("%d\n", valMax);
}
}
return 0;
}