#include <fstream>
#include <iostream>
using namespace std;
ifstream in("arbint.in");
ofstream out("arbint.out");
int n, m, a[110000], x, y, arb[500000];
void create(int node, int left, int right)
{
if (left == right)
arb[node] = a[left];
else
{
create(2 * node, left, (left + right) / 2);
create(2 * node + 1, (left + right) / 2 + 1, right);
arb[node]=max(arb[2*node],arb[2*node+1]);
}
}
void update(int node,int left, int right,int pos,int val)
{
if(pos<left || pos>right)
return;
if (left == right)
arb[left] = val;
else
{
int mij = (left + right) / 2;
// if (pos >= mij)
update(2 * node,left,mij,pos,val);
update(2 * node + 1,mij+1,right, pos, val);
// else
arb[node]=max(arb[2*node],arb[2*node+1]);
}
}
int query(int node, int left, int right, int i, int j)
{
if(right<i || j<left)
return 0;
int mij=(left+right)/2;
if (left >= i && right <= j)
return arb[node];
return max(query(2*node,left,mij,i,j),query(2*node+1,mij+1,right,i,j));
}
int main()
{
in >> n >> m;
for (int i = 1; i <= n; i++)
{
in >> a[i];
}
int caz;
create(1,1,n);
for(int i=1;i<=m;i++)
{
in>>caz>>x>>y;
if(caz==0)
{
out<<query(1,1,n,x,y)<<endl;
}
else
{
if(caz==1)
update(1,1,n,x,y);
}
}
return 0;
out.close();
in.close();
}