#include <fstream>
using namespace std;
ifstream cin("arbint.in");
ofstream cout("arbint.out");
int n, m, a[100001], arbore[400001], cnt;
long long v[100001];
void constr(int nod, int st, int dr){
if(st == dr) arbore[nod] = a[st];
else{
int mij = (st + dr) / 2;
constr(nod * 2, st, mij);
constr(nod*2+1, mij+1, dr);
arbore[nod] = max(arbore[nod*2],arbore[nod*2+1]);
}
}
void update(int nod, int st, int dr, int poz, int val){
if(st == dr) arbore[nod] = val;
else{
int mij = (st+dr) / 2;
if(poz <= mij) update(nod*2, st, mij, poz, val);
else update(nod*2+1, mij+1, dr, poz, val);
arbore[nod] = max(arbore[nod*2],arbore[nod*2+1]);
}
}
long long query(int nod, int st, int dr, int qst,int qdr){
if(qst <= st && dr <= qdr) return arbore[nod];
else{
int mij = (st + dr) / 2;
if(qdr <= mij) return query(nod*2, st, mij, qst, qdr);
if(mij+1 <= qst) return query(nod*2+1, mij+1, dr, qst, qdr);
return max(query(nod*2, st, mij, qst, qdr),query(nod*2+1, mij+1, dr, qst, qdr));
}
}
int main()
{
int p, x, y;
cin >> n >> m;
for(int i = 1; i <= n; ++i) cin >> a[i];
constr(1, 1, n);
for(int i = 1; i <= m; ++i){
cin >> p >> x >> y;
if(p == 1) update(1, 1, n, x, y);
else cout << query(1, 1, n, x, y) << '\n';
}
return 0;
}