#include <iostream>
#include <cstdio>
#define Nmax 100100
using namespace std;
int n,m,x,y;
int noduri[Nmax];
class ArboreDeIntervale
{
private :
int solution;
public :
void creat(int pos , int left ,int right);
void update(int pos , int left , int right);
void query(int pos , int left ,int right);
int GetSolution();
int Arbore[4*Nmax];
ArboreDeIntervale();
void SetSolution(int x);
};
ArboreDeIntervale:ArboreDeIntervale()
{
solution = 0;
}
int ArboreDeIntervale::GetSolution()
{
return solution;
}
void ArboreDeIntervale::SetSolution(int x)
{
solution = x;
}
void ArboreDeIntervale::update(int pos , int left , int right)
{
if(left == right)
{
Arbore[pos] = y;
return;
}
int middle = (left + right)/2;
IF( x < middle)
update(2*pos,left,middle);
else
update(2*pos+1,middle+1,right);
Arbore[pos] = max(Arbore[2*pos],Arbore[2*pos+1]);
}
void ArboreDeIntervale::creat(int pos ,int left , int right)
{
if(left == right)
{
Arbore[pos] = noduri[left];
return;
}
int middle = (left + right) / 2;
creat(2*pos,left,middle);
creat(2*pos+1,middle+1,right);
Arbore[pos] = max(Arbore[2*pos],Arbore[2*pos+1]);
}
void ArboreDeIntervale::query(int pos ,int left ,int right)
{
if(x <= left && y >= right)
{
solution = max(Arbore[pos],solution);
return;
}
int middle = (left+right) /2;
if( < middle)
query(2*pos,left,middle);
else
query(2*pos+1,middle+1,right);
}
void read()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
scanf("%d %d",&n,&m);
ArboreDeIntervale obiect;
for(int i = 1 ; i <= n ; i++)
scanf("%d ",&noduri[i]);
obiect.creat(1,1,n);
for(int i = 0 ; i < m ; i++)
{
int task,left,right;
scanf("%d %d %d",&task,&x,&y);
if(task == 1)
obiect.update(1,1,n);
else
{
obiect.SetSolution(0);
obiect.query(1,1,n);
printf("%d\n",obiect.GetSolution());
}
}
}
int main()
{
read();
return 0;
}