#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fs first
#define sc second
#define pob pop_back
#define pub push_back
#define eps 1E-7
#define sz(a) a.size()
#define count_one __builtin_popcount;
#define count_onell __builtin_popcountll;
#define fastIO ios_base::sync_with_stdio(false)
#define PI (acos(-1.0))
#define linf (1LL<<62)//>4e18
#define inf (0x7f7f7f7f)//>2e9
#define MAXN 100010
#define nds ((nod << 1))
#define ndr ((nod << 1) + 1)
int n, m, val, st, dr, pos, maxx;
int arb[4*MAXN + 100];
void query(int nod, int l, int r) {
if(st <= l && r <= dr) {
maxx = max(maxx, arb[nod]);
return;
}
int mid = (l + r) >> 1;
if(mid >= st)
query(nds, l, mid);
if(mid < dr)
query(ndr, mid + 1, dr);
}
void update(int nod, int l, int r) {
if(l == r) {
arb[nod] = val;
//cerr << l << " " << val << "\n";
return;
}
int mid = (l + r) >> 1;
if(mid >= pos)
update(nds, l, mid);
else
update(ndr, mid + 1, r);
arb[nod] = max(arb[nds], arb[ndr]);
}
void read() {
#ifndef ONLINE_JUDGE
assert(freopen("arbint.in", "r", stdin));
assert(freopen("arbint.out", "w", stdout));
#endif
int tip, x, y;
assert(scanf("%d%d", &n, &m));
for(int i = 1; i <= n; ++i)
assert(scanf("%d", &val)),
pos = i,
update(1, 1, n);
// build(1, 1, n);
//for(int i = 1; i < 50; ++i)
// cout << arb[i] << " ";
while(m--) {
scanf("%d%d%d", &tip, &x, &y);
if(tip == 0)
maxx = -1,
st = x,
dr = y,
query(1, 1, n),
printf("%d\n", maxx);
if(tip == 1)
val = y,
pos = x,
update(1, 1, n);
}
}
int main() {
read();
return 0;
}