#include <cstdio>
#include <algorithm>
using namespace std;
int N, M;
int V[100001];
int A[1<<18];
int a, b;
int rez;
#define ns (nod<<1)
#define nd (ns + 1)
#define mj ((st + dr) >> 1)
void make (int nod, int st, int dr){
if (st >= dr) A[nod] = V[st];
else{
make (ns, st, mj);
make (nd, mj + 1, dr);
A[nod] = max (A[ns], A[nd]);
}
}
void update (int nod, int st, int dr){
if (st >= dr) A[nod] = b;
else{
if (mj >= a) update (ns, st, mj);
else update (nd, mj + 1, dr);
A[nod] = max (A[ns], A[nd]);
}
}
void query (int nod, int st, int dr){
if (a <= st && dr <= b) rez = max (rez, A[nod]);
else{
if (a <= mj) query (ns, st, mj);
if (b > mj) query (nd, mj + 1, dr);
}
}
void read (){
int i, t;
scanf ("%d %d\n", &N, &M);
for (i = 1; i <= N; ++ i) scanf (" %d", V + i);
make (1, 1, N);
for (i = 1; i <= M; ++ i){
scanf ("%d %d %d\n", &t, &a, &b); rez = -1;
if (t) update (1, 1, N);
else query (1, 1, N), printf ("%d\n", rez);
}
}
int main (){
freopen ("arbint.in", "r", stdin);
freopen ("arbint.out", "w", stdout);
read ();
return 0;
}