#include <bits/stdc++.h>
#define maxim 100009
using namespace std;
/*
ifstream f("../dt.in");
ofstream g("../dt.out");
*/
ifstream f("arbint.in");
ofstream g("arbint.out");
int n,m,v[maxim];
int tree[maxim<<2];
void creare(int nod ,int i,int j)
{
if (i==j)
tree[nod]=v[i];
else
{
int m=(i+j)/2;
creare(nod*2,i,m);
creare(nod*2+1,m+1,j);
tree[nod]=max(tree[nod*2],tree[nod*2+1]);
}
}
void update(int nod,int i ,int j, const int poz, const int x )
{
if (i==j)
tree[nod]=x;
else
{
int m=(i+j)/2;
if (poz <= m)
update(nod*2,i,m,poz,x);
else
update(nod*2+1,m+1,j,poz,x);
tree[nod]=max(tree[nod*2],tree[nod*2+1]);
}
}
int findmax(int nod , int i, int j , const int a , const int b)
{
if (a<= i && b>=j) // i-j e inclus complet in a-b
return tree[nod];
int m=(i+j)/2;
int ans=0;
if (a<=m)
ans=max(ans,findmax(nod*2,i,m,a,b));
if (b>m)
ans=max(ans,findmax(nod*2+1,m+1,j,a,b));
return ans;
}
int main()
{
f>>n>>m;
for (int i=1;i<=n;i++)
f>>v[i];
creare(1,1,n);
for (int i=1;i<=m;i++)
{
int x,a,b;
f>>x>>a>>b;
if (x==0)
g<<findmax(1,1,n,a,b)<<'\n';
else
update(1,1,n,a,b);
}
}