#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
void insert(int arbore[], int x, int poz, int nod, int st, int dr) {
if (st == dr) {
arbore[nod] = x;
return;
}
int m = (st + dr) / 2;
if (poz <= m)
insert(arbore, x, poz, 2 * nod, st, m);
else
insert(arbore, x, poz, 2 * nod + 1, m + 1, dr);
arbore[nod] = max(arbore[2 * nod], arbore[2 * nod + 1]);
}
int maxim = -1;
void query(int arbore[], int start, int stop, int nod, int st, int dr) {
if (start <= st && dr <= stop) {
if (arbore[nod] > maxim)
maxim = arbore[nod];
return;
}
int m = (st + dr) / 2;
if(start <= m)
query(arbore, start, stop, 2 * nod, st, m);
if(m < stop)
query(arbore, start, stop, 2 * nod + 1, m + 1, dr);
}
int arbore[1000001], v[1000001];
int main() {
int n, m, i, x, a, b;
fin >> n >> m;
for(i = 1; i <= n; ++i) {
fin >> x;
insert(arbore, x, i, 1, 1, n);
}
for(i = 0; i < m; ++i) {
fin >> x >> a >> b;
if(x == 0) {
maxim = -1;
query(arbore, a, b, 1, 1, n);
fout << maxim << "\n";
}
else {
insert(arbore, b, a, 1, 1, n);
}
}
return 0;
}