# include <fstream>
# define NMAX 100001
using namespace std;
int N, M;
int A[5*NMAX];
long pmax;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
inline int maxim(int a, int b) {
if(a > b) return a;
return b;
}
void arb_update(int nod, int st, int dr, int val, int poz) {
if(st == dr) A[nod] = val;
else {
int m = (st+dr)>>1;
if(poz <= m) arb_update(nod<<1, st, m, val, poz);
else arb_update((nod<<1)+1, m+1, dr, val, poz);
A[nod] = maxim(A[nod<<1], A[(nod<<1)+1]);
}
}
void arb_querry(int nod, int st, int dr, int a, int b) {
if(a <= st && dr <= b) {
if(pmax < A[nod])
pmax = A[nod];
}
else {
int m = (st+dr)>>1;
if(a <= m) arb_querry(nod<<1, st, m, a, b);
if(b > m) arb_querry((nod<<1)+1, m+1, dr, a, b);
}
}
void citire() {
int i, val;
fin >> N >> M;
for(i = 1; i <= N; ++ i) {
fin >> val;
arb_update(1, 1, N, val, i);
}
}
void more() {
int i, cod, a, b;
for(i = 1; i <= M; ++ i) {
fin >> cod >> a >> b;
if(!cod) {
pmax = -1;
arb_querry(1, 1, N, a, b);
fout << pmax << '\n';
}
else arb_update(1, 1, N, b, a);
}
}
int main() {
citire();
more();
return 0;
}