#include <iostream>
#include <fstream>
#include <vector>
#include <string.h>
using namespace std;
ifstream in("arbint.in");
ofstream out("arbint.out");
#define ll long long
const int NMax = 100000;
const int arbMax = 262143 + 5;
int N,M;
int arb[arbMax];
void update(int,int,int,int,int);
int query(int,int,int,int,int);
int main() {
/*
int pw = 1;
while (pw < NMax) {
pw <<= 1;
}
out<<2*pw - 1<<'\n';
//*/
in>>N>>M;
for (int i=1;i<=N;++i) {
int val;
in>>val;
update(1,1,N,i,val);
}
while (M--) {
int tip,a,b;
in>>tip>>a>>b;
if (tip == 1) {
update(1,1,N,a,b);
}
else {
out<<query(1,1,N,a,b)<<'\n';
}
}
in.close();out.close();
return 0;
}
void update(int nod,int st,int dr,int pos,int val) {
if (st == dr) {
arb[nod] = val;
return;
}
int mij = (st+dr)>>1,
fSon = nod<<1,
sSon = fSon + 1;
if (pos <= mij) {
update(fSon,st,mij,pos,val);
}
else {
update(sSon,mij+1,dr,pos,val);
}
arb[nod] = max(arb[fSon],arb[sSon]);
}
int query(int nod,int st,int dr,int a,int b) {
if (a <= st && dr <= b) {
return arb[nod];
}
int mij = (st+dr)>>1,
fSon = nod<<1,
sSon = fSon + 1,
mx = 0;
if (a <= mij) {
mx = query(fSon,st,mij,a,b);
}
if (mij + 1 <= b) {
mx = max(mx,query(sSon,mij+1,dr,a,b));
}
return mx;
}