#include <algorithm>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin ("arbint.in");
ofstream fout("arbint.out");
int n, m ,x ,y, i, sol, ok;
int a[300010];
void build(int nod, int st, int dr)
{
if(st==dr)
fin>>a[nod];
else
{
int mid=(st+dr)/2;
build(2*nod, st, mid);
build(2*nod+1, mid+1, dr);
a[nod]=max(a[2*nod], a[2*nod+1]);
}
}
void update(int nod, int st, int dr, int poz, int val)
{
if(st==dr)
a[nod]=val;
else
{
int mid=(st+dr)/2;
if(poz<=mid)
update(2*nod, st, mid, poz, val);
if(poz>mid)
update(2*nod+1, mid+1, dr, poz, val);
a[nod]=max(a[2*nod], a[2*nod+1]);
}
}
void vas(int nod, int st, int dr, int x, int y)
{
if(x<=st&&y>=dr)
sol=max(sol, a[nod]);
else
{
int mid=(st+dr)/2;
if(x<=mid)
vas(2*nod, st, mid, x, y);
if(mid+1<=y)
vas(2*nod+1, mid+1, dr, x ,y);
}
}
int main(){
fin>>n>>m;
build(1, 1, n);
for(i=1;i<=m;i++)
{
fin>>ok>>x>>y;
if(ok==0)
{
sol=0;
vas(1, 1, n, x, y);
fout<<sol<<"\n";
}
else
update(1, 1 , n, x, y);
}
fin.close();
fout.close();
return 0;
}