#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#define MOD 105011
#define NMAX 100005
#define INF 0x3f3f3f3f
#define pb push_back
using namespace std;
FILE *fin = freopen("arbint.in", "r", stdin);
FILE *fout = freopen("arbint.out", "w", stdout);
typedef pair<int, int> pii;
int v[NMAX];
int ai[4 * NMAX];
int ansQ;
void build(int poz, int st, int dr);
void query(int poz, int st, int dr, int qst, int qdr);
void update(int poz, int st, int dr, int x, int pozUpdate);
int main() {
int n, m, i, q, a, b;
cin >> n >> m;
for (i = 1; i <= n; ++i)
cin >> v[i];
build(1, 1, n);
for (i = 0; i < m; ++i) {
cin >> q >> a >> b;
if (q == 0) {
ansQ = -1;
query(1, 1, n, a, b);
cout << ansQ << '\n';
}
else
update(1, 1, n, b, a);
}
return 0;
}
void build(int poz, int st, int dr) {
int mid = ((st + dr) >> 1), fs = (poz << 1);
if (st == dr) {
ai[poz] = v[st];
return;
}
build(fs, st, mid); build(fs + 1, mid + 1, dr);
ai[poz] = max(ai[fs], ai[fs + 1]);
}
void query(int poz, int st, int dr, int qst, int qdr) {
int mid = ((st + dr) >> 1), fs = (poz << 1);
if (st > qdr || dr < qst)
return;
if (qst <= st && qdr >= dr) {
ansQ = max(ansQ, ai[poz]);
return;
}
if (qst <= mid)
query(fs, st, mid, qst, qdr);
if (qdr > mid)
query(fs + 1, mid + 1, dr, qst, qdr);
}
void update(int poz, int st, int dr, int x, int pozUpdate) {
if (st == dr) {
ai[poz] = x;
return;
}
int mid = ((st + dr) >> 1), fs = (poz << 1);
if (pozUpdate <= mid)
update(fs, st, mid, x, pozUpdate);
if (pozUpdate > mid)
update(fs + 1, mid + 1, dr, x, pozUpdate);
ai[poz] = max(ai[fs], ai[fs + 1]);
}