#include <fstream>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <bitset>
#include <climits>
#include <set>
#include <cmath>
using namespace std;
ifstream cin("arbint.in");
ofstream cout("arbint.out");
#define dim 100001
int aint[4*dim+101], n, m, t, a, b;
inline void build(int node, int st, int dr)
{
if(st == dr)
{
cin>>aint[node];
return ;
}
int mid = (st+dr)>>1;
build(node<<1, st, mid); ///a<<1 = 2*a
build(node<<1|1, mid+1, dr); /// a<<1|1 = 2*a+1
aint[node] = max(aint[node<<1], aint[node<<1|1]);
}
inline void update(int node, int st, int dr, int poz, int val)
{
if(st == dr)
{
aint[node] = val;
return ;
}
int mid = (st+dr)>>1;
if(poz <= mid)
update(node<<1, st, mid, poz, val);
if(poz > mid)
update(node<<1|1, mid+1, dr, poz, val);
aint[node] = max(aint[node<<1], aint[node<<1|1]);
}
inline int query(int node, int st, int dr, int a, int b)
{
if(st >= a && dr <= b) ///overlapping
return aint[node];
else if(dr < a || b < st) ///no overlapping
return -1;
else ///partial overlapping
{
int mid = (st+dr)>>1;
if(a <= mid && b > mid)
return max(query(node<<1, st, mid, a, b), query(node<<1|1, mid+1, dr, a, b));
else if(a <= mid)
return query(node<<1, st, mid, a, b);
else
return query(node<<1|1, mid+1, dr, a, b);
}
}
int main()
{
cin>>n>>m;
build(1,1,n);
for(int x = 1 ; x <= m ; x++)
{
cin>>t>>a>>b;
if(t == 1)
update(1,1,n,a,b);
else
cout<<query(1,1,n,a,b)<<'\n';
}
}