/*
ID: gabriel100
LANG: C++
TASK:
*/
#include <cstdio>
#include <algorithm>
//#include <time.h>
#include <queue>
#include <cmath>
#include <stack>
#include <fstream>
#include <bitset>
#include <set>
#define nl '\n'
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define eb(x) emplace_back(x)
#define ull unsigned long long
#define ll long long
#define ProblemName "arbint"
#define LocalName "data"
#ifdef INFOARENA
#define Filename ProblemName
#else
#define Filename LocalName
#endif
#define Input Filename".in"
#define Output Filename".out"
using namespace std;
ifstream cin(Input);
ofstream cout(Output);
template<class a, class type>
void print(a v, type t) {
for_each(all(v), [](type x) { cout << x.first << ' '; });
cout << nl;
}
#define N 100'000'0
int v[N * 2+ 'S'+'T'+'E'+'F'+'F'+'Y'];
int n, q, a, b;
int cod;
void update(int nod,int st,int dr,int pos,int val){
if(st == dr){
v[nod] = val;
} else {
int mij = (st+dr) >> 1;
if(pos <= mij) update(2*nod,st,mij,pos,val);
else update(2*nod+1,mij+1,dr,pos,val);
v[nod] = max(v[2*nod],v[2*nod+1]); // cand ne intoarcem
}
}
int mx;
void GetMax(int nod,int st,int dr,int a, int b){
if(st >= a && dr <= b){
mx = max(mx,v[nod]);
} else {
int mij = (st+dr) >> 1;
if(a<=mij) GetMax(2*nod,st,mij,a,b);
if(b>mij) GetMax(2*nod+1,mij+1,dr,a,b);
}
}
int main() {
// clock_t tStart = clock();
ios_base::sync_with_stdio(false);
cin >> n >> q;
for (int i = 1; i <= n; ++i) {
cin >> a;
update(1, 1, n, i, a);
}
while (q--) {
cin >> cod >> a >> b;
if (!cod) {
mx = -1;
GetMax(1, 1, n, a, b);
cout << mx << nl;
} else {
update(1, 1, n, a, b);
}
}
// printf("\nTime taken: %.2fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
cout.close();
}