#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "arbint";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif
const int NMAX = 100000 + 5;
int N, M;
int AI[4 * NMAX];
int V[NMAX];
void build(int nod, int lo, int hi) {
if(lo == hi) {
AI[nod] = V[lo];
return;
}
int mi = (lo + hi) / 2;
build(2 * nod + 0, lo, mi + 0);
build(2 * nod + 1, mi + 1, hi);
AI[nod] = max(AI[2 * nod + 0], AI[2 * nod + 1]);
}
void update(int nod, int lo, int hi, int poz, int val) {
if(lo == hi) {
AI[nod] = val;
V[poz] = val;
return;
}
int mi = (lo + hi) / 2;
if(poz <= mi)
update(2 * nod + 0, lo, mi + 0, poz, val);
else
update(2 * nod + 1, mi + 1, hi, poz, val);
AI[nod] = max(AI[2 * nod + 0], AI[2 * nod + 1]);
}
int query(int nod, int lo, int hi, int L, int R) {
if(L <= lo && hi <= R)
return AI[nod];
if(hi < L || R < lo)
return -1;
int mi = (lo + hi) / 2;
int q1 = query(2 * nod + 0, lo, mi + 0, L, R);
int q2 = query(2 * nod + 1, mi + 1, hi, L, R);
return max(q1, q2);
}
int main() {
int i,t,x,y;
#ifndef ONLINE_JUDGE
freopen(inputFile.c_str(), "r", stdin);
freopen(outputFile.c_str(), "w", stdout);
#endif
scanf("%d%d", &N, &M);
for(i = 1; i <= N; i++)
scanf("%d", &V[i]);
build(1, 1, N);
while(M--) {
scanf("%d%d%d", &t, &x, &y);
if(t == 0) {
printf("%d\n", query(1, 1, N, x, y));
continue;
} else {
update(1, 1, N, x, y);
continue;
}
}
return 0;
}