#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
#define Nmax 100005
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n, m, A[5 * Nmax], maxim;
void Update(const int& nod, const int& st, const int& dr, const int& val, const int& pos) {
if(st == dr) {
A[nod] = val;
return;
}
int mij = (st + dr) / 2;
if(pos <= mij)
Update(2 * nod, st, mij, val, pos);
else
Update(2 * nod + 1, mij + 1, dr, val, pos);
A[nod] = max(A[nod * 2], A[nod * 2 + 1]);
}
int Query(const int& nod, const int& st, const int& dr, const int& a, const int&b) {
if(a <= st && dr <= b) {
//if(A[nod] > maxim) maxim = A[nod];
return A[nod];
}
int mij = (st + dr) / 2;
//if(a <= mij) Query(2 * nod, st, mij, a, b);
//if(mij < b) Query(2 * nod + 1, mij + 1, dr, a, b);
int q1 = 0, q2 = 0;
if(a <= mij) q1 = Query(2 * nod, st, mij, a, b);
if(mij < b) q2 = Query(2 * nod + 1, mij + 1, dr, a, b);
return max(q1, q2);
}
int main()
{
fin >> n >> m;
int op, x, y;
for(int i = 1; i <= n; ++i) {
fin >> x;
Update(1, 1, n, x, i);
}
for(int j = 1; j <= m; ++j) {
fin >> op >> x >> y;
if(!op) {
maxim = -1;
fout << Query(1, 1, n, x, y) << '\n';
//fout << maxim << '\n';
}
else
Update(1, 1, n, y, x);
}
return 0;
}