#include <bits/stdc++.h>
using namespace std;
ifstream fin ("arbint.in");
ofstream fout ("arbint.out");
const int NMAX=1e5+5;
int input[NMAX],segTree[4*NMAX],n,m;
void read()
{
fin>>n>>m;
for(int i=0;i<n;i++) fin>>input[i];
}
void ConstructTree(int low,int high,int poz)
{
if(low==high)
{
segTree[poz]=input[low];
return;
}
int mid=(low+high)/2;
ConstructTree(low,mid,2*poz+1);
ConstructTree(mid+1,high,2*poz+2);
segTree[poz]=max(segTree[2*poz+1],segTree[2*poz+2]);
}
int query(int qlow,int qhigh,int low,int high,int poz)
{
if(low>qhigh || high<qlow) /// no overlap
return 0;
if(low>=qlow && high<=qhigh) /// total overlap
return segTree[poz];
int mid=(low+high)/2;
return max(query(qlow,qhigh,low,mid,2*poz+1),query(qlow,qhigh,mid+1,high,2*poz+2));
}
void update(int low,int high,int poz,int index,int val)
{
if(low==high)
{
segTree[poz]=val;
return;
}
int mid=(low+high)/2;
if(index<=mid)
update(low,mid,2*poz+1,index,val);
else update(mid+1,high,2*poz+2,index,val);
segTree[poz]=max(segTree[2*poz+1],segTree[2*poz+2]);
}
int main()
{
int op,a,b;
read();
ConstructTree(0,n-1,0);
while(m--)
{
fin>>op>>a>>b;
if(!op) fout<<query(a-1,b-1,0,n-1,0)<<'\n';
else update(0,n-1,0,a-1,b);
}
return 0;
}