/* Vlad Voicu 2012 */
/* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details. */
#include <cstdio>
#include <string>
#include <iostream>
int val, poz, max, start, end;
int v[450000];
int maxim(int a, int b) {
if (a > b) {
return a;
}
return b;
}
void Update(int nod, int left, int right) {
if (left == right) {
v[nod] = val;
return;
}
int div = left + (right - left) / 2;
if (poz <= div) {
Update(nod*2, left, div);
} else {
Update(nod*2+1, div+1, right);
}
v[nod] = maxim(v[nod*2], v[nod*2+1]);
}
void Query(int nod, int left, int right) {
if (start <= left && right <= end) {
if (max < v[nod])
max = v[nod];
return;
}
int div = left + (right - left) / 2;
if (start <= div) Query(2*nod, left, div);
if (div < end) Query(2*nod+1, div+1, right);
}
int main() {
freopen("arbint.in", "r", stdin);
freopen("arbint.out", "w", stdout);
int n, m, i;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++) {
poz = i + 1;
scanf("%d", &val);
Update(1, 1, n);
}
for (i = 0; i < m; i++) {
int op;
scanf("%d", &op);
if (op == 0) {
max = -1;
scanf("%d%d", &start, &end);
Query(1, 1, n);
printf("%d\n", max);
} else {
scanf("%d%d", &poz, &val);
Update(1, 1, n);
}
}
return 0;
}