#include <cstdio>
#include <iostream>
#include <fstream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctype.h>
#include <cstring>
#include <string>
#include <ctime>
#include <cassert>
#include <utility>
#define LIM 100001
using namespace std;
int pos, val, n, a, b, maxim, v[LIM];
int A[4 * LIM];
void initARB(int nod, int st, int dr) {
if(st == dr) {
A[nod] = v[st];
return;
}
int mij = (st + dr) / 2;
initARB(2 * nod, st, mij);
initARB(2 * nod + 1, mij + 1, dr);
A[nod] = max(A[2 * nod], A[2 * nod + 1]);
}
void updateARB(int nod, int st, int dr) {
if(st == dr) {
A[nod] = val;
return;
}
int mij = (st + dr) / 2;
if(pos <= mij) {
updateARB(2 * nod, st, mij);
}
else {
updateARB(2 * nod + 1, mij + 1, dr);
}
A[nod] = max(A[2 * nod], A[2 * nod + 1]);
}
void queryARB(int nod, int st, int dr) {
if(a <= st && dr <= b) {
if(maxim < A[nod]) {
maxim = A[nod];
}
return;
}
// aici incerc sa includ intervalul [st, dr] in intervalul [a, b]
int mij = (st + dr) / 2;
if(a <= mij) {
queryARB(2 * nod, st, mij);
}
if(mij < b) {
queryARB(2 * nod + 1, mij + 1, dr);
}
}
int main() {
freopen("arbint.in", "r", stdin);
freopen("arbint.out","w", stdout);
int m, op;
scanf("%d %d", &n, &m);
for(int i = 1; i <= n; i++) {
scanf("%d", &v[i]);
}
initARB(1, 1, n);
for(int i = 0; i < m; i++) {
scanf("%d %d %d", &op, &a, &b);
if(op == 0) {
maxim = -1;
queryARB(1, 1, n);
printf("%d\n", maxim);
} else {
pos = a;
val = b;
updateARB(1, 1, n);
}
}
return 0;
}