#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int const N=(int)1e5+5,V=4*N+100;
int f[V],n,v[N],ex[N];
void build(int s,int d,int pz)
{
if(s==d)
{
f[pz]=v[s];
ex[s]=pz;
return;
}
int m=(s+d)/2;
build(s,m,pz*2);
build(m+1,d,pz*2+1);
f[pz]=max(f[pz*2],f[pz*2+1]);
}
int mx(int x,int y,int s,int d,int pz)
{
int m=(s+d)/2;
if(d<x || s>y)
return 0;
if(x<=s && y>=d)
return f[pz];
return max(mx(x,y,s,m,pz*2),mx(x,y,m+1,d,pz*2+1));
}
void upd(int pz)
{
if(!pz)
return;
f[pz]=max(f[pz*2],f[pz*2+1]);
upd(pz/2);
}
int main()
{
int q,a,x,y;
fin>>n>>q;
for(int i=1;i<=n;i++)
fin>>v[i];
build(1,n,1);
while(q--)
{
fin>>a>>x>>y;
if(a==0)
{if(x>y)swap(x,y);fout<<mx(x,y,1,n,1)<<'\n';}
else
{ex[x]=y;upd(ex[x]/2);}
}
}