#include <fstream>
using namespace std;
ifstream cin ("arbint.in");
ofstream cout ("arbint.out");
#define N 100000
int v[N*4];
void update(int poz, int val, int k){
poz+=(k-1);
v[poz]=val;
while (poz>1){
poz/=2;
v[poz]=max(v[2*poz], v[2*poz+1]);
}
}
int query(int poz, int a, int b, int st, int dr){
int mij;
if (a==st && b==dr)
return v[poz];
mij=(st+dr)/2;
if (b<=mij)
return query(2*poz, a, b, st, mij);
if (mij+1<=a)
return query(2*poz+1, a, b, mij+1, dr);
return max(query(2*poz, a, mij, st, mij), query(2*poz+1, mij+1, b, mij+1, dr));
}
int main()
{
int n,q,i,k,cer,a,b;
cin >> n >> q;
k=1;
while (k<n)
k*=2;
for (i=1; i<=n; i++)
cin >> v[k-1+i];
for (i=k-1; i>=1; i--)
v[i]=max(v[2*i], v[2*i+1]);
for (i=0; i<q; i++){
cin >> cer >> a >> b;
if (cer==0)
cout << query(1, a, b, 1, k) << '\n';
else
update(a, b, k);
}
return 0;
}