#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int v[100005], n, arbint[800020], m, t, a, b;
void citire() {
fin >> n >> m;
for(int i = 1; i <= n; i++)
fin >> v[i];
}
int query(int nod, int st, int dr, int a, int b) {
if(a <= st && dr <= b)
return arbint[nod];
int res = -1;
int m = (st+dr)/2;
if(a <= m)
res = max(res, query(2*nod, st, m, a, b));
if(b > m)
res = max(res, query(2*nod+1, m+1, dr, a, b));
return res;
}
void update(int nod, int st, int dr, int poz) {
if(st == dr) {
arbint[nod] = v[st];
return;
}
int m = (st+dr)/2;
if(m >= poz)
update(2*nod, st, m, poz);
else
update(2*nod+1, m+1, dr, poz);
arbint[nod] = max(arbint[2*nod], arbint[2*nod+1]);
}
int main() {
citire();
for(int i = 1; i <= n; i++)
update(1, 1, n, i);
while(m--) {
fin >> t >> a >> b;
if(t == 0)
fout << query(1, 1, n, a, b) << '\n';
else {
v[a] = b;
update(1, 1, n, a);
}
}
}