#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
vector<int>v;
int maxx,n,ai[100001];
void build_ai(int x, int st, int dr)
{
int m;
if(st==dr)
ai[x]=v[st];
else
{
m=(st+dr)/2;
build_ai(2*x,st,m);
build_ai(2*x+1,m+1,dr);
if(ai[2*x+1]>ai[2*x])
ai[x]=ai[2*x+1];
else
ai[x]=ai[2*x];
}
}
void maxim(int x, int st, int dr, int a, int b)
{
int m;
if(a<=st && dr<=b)
{
if(ai[x]>maxx)
maxx=ai[x];
}
else
{
m=(st+dr)/2;
if(a<=m)
maxim(2*x,st,m,a,b);
if(b>m)
maxim(2*x+1,m+1,dr,a,b);
}
}
void update(int x, int st, int dr, int poz)
{
int m;
if(st==dr)
ai[x]=v[st];
else
{
m=(st+dr)/2;
if(m<poz)
update(2*x+1,m+1,dr,poz);
else
update(2*x,st,m,poz);
}
if(ai[2*x+1]>ai[2*x])
ai[x]=ai[2*x+1];
else
ai[x]=ai[2*x];
}
void f0(int a,int b)
{
maxim(1,1,n,a,b);
g<<maxx<<'\n';
maxx=0;
}
void f1(int a,int b)
{
ai[a]=b;
update(1,1,n,a);
}
int main()
{
int a,b,m,i;
bool y;
f>>n>>m;
v.push_back(0);
for(i=1;i<=n;i++)
{
f>>a;
v.push_back(a);
}
build_ai(1,1,n);
for(i=1;i<=m;i++)
{
f>>y>>a>>b;
if(y==0)
f0(a,b);
else
f1(a,b);
}
return 0;
}