#include <iostream>
#include <fstream>
using namespace std;
int n,m,a,t[100001];
int maxx=-1;
ifstream f("arbint.in");
ofstream g("arbint.out");
void pluss(int poz, int x,int y,int p)
{
if (poz==x && x==y)
t[p]=a;
else
{
if (t[p]<a)
t[p]=a;
int m=((x+y)-1)/2;
if (poz<=m)
pluss(poz,x,m,2*p);
else
pluss(poz,m+1,y,2*p+1);
}
}
void actt(int poz, int x,int y,int p)
{
if (poz==x && x==y)
t[p]=a;
else
{
if (t[p]<a)
t[p]=a;
int m=((x+y)-1)/2;
if (poz<=m)
{
t[p]=max(a,t[2*p+1]);
actt(poz,x,m,2*p);
}
else
{
t[p]=max(a,t[2*p]);
actt(poz,m+1,y,2*p+1);
}
}
}
void rez(int x,int y, int x1, int y1, int p)
{
if(x1==x && y==y1 && maxx<t[p])
maxx=t[p];
else
{
int m = (x+y-1)/2;
if(x1<=m && y1<=m)
rez(x,m,x1,y1,2*p);
else
if(x1 > m && y1>m)
rez(m+1,y,x1,y1,2*p+1);
else
{
int m1= (x1+y1-1)/2;
rez(x,m,x1,m1,2*p);
rez(m+1,y,m1+1,y,2*p+1);
}
}
}
void citire()
{
f>>n>>m;
for (int i=1;i<=n;i++)
{
f>>a;
pluss(i,1,n,1);
}
for(int i=0;i<m;i++)
{
int tip,x;
f>>tip>>x>>a;
if(tip==1)
actt(x,1,n,1);
else
{
maxx=-1;
rez(1,n,x,a,1);
cout << maxx;
}
}
// for (int i=1;i<=15;i++)
// cout<<t[i]<<" ";
}
int main()
{
citire();
return 0;
}