#include <bits/stdc++.h>
#define Nmax 100005
using namespace std;
ifstream f ("arbint.in");
ofstream g ("arbint.out");
int heap[4*Nmax],a,b,i,x,y,n,Max,t;
inline void heapInsert(int val,int poz,int st,int dr,int nod)
{
if(st == dr)
{
heap[nod] = val;
return;
}
int mij = (st + dr) / 2;
if(poz <= mij)
heapInsert(val,poz,st,mij,2*nod);
else heapInsert(val,poz,mij + 1,dr, 2*nod + 1);
heap[nod] = max(heap[nod*2],heap[nod*2 + 1]);
}
inline void heapQuery(int a,int b,int st,int dr,int nod)
{
if(a <= st && dr <= b)
{
Max = max(Max,heap[nod]);
return;
}
int mij = (st + dr) / 2;
if(a <= mij)
heapQuery(a,b,st,mij,2*nod);
if(b >= mij + 1)
heapQuery(a,b,mij + 1,dr,2*nod + 1);
}
int main()
{
f >> n >> t;
for(i = 1;i <= n;i++)
f >> x,heapInsert(x,i,1,n,1);
for(i = 1;i <= t;i++)
{
f >> x >> a >> b;
switch(x)
{
case 1:
heapInsert(b,a,1,n,1);
break;
case 0:
Max = -1;
heapQuery(a,b,1,n,1);
g << Max << '\n';
break;
}
}
return 0;
}