#include <bits/stdc++.h>
using namespace std;
vector<int> tree;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
void update(int pos, int node, int left, int right, int value) {
if (left == right) {
tree[node] = value;
return;
}
int mij = (left + right) / 2;
if (pos <= mij) {
update(pos, 2 * node, left, mij, value);
} else {
update(pos, 2 * node + 1, mij + 1, right, value);
}
tree[node] = max(tree[2 * node], tree[2 * node + 1]);
}
void query(int node, int a, int b, int left, int right, int &maxim) {
if (left >= a && right <= b) {
maxim = max(maxim, tree[node]);
return;
}
int mij = (left + right) / 2;
if (mij >= a) {
query(2 * node, a, b, left, mij, maxim);
}
if (mij < b) {
query(2 * node + 1, a, b, mij + 1, right, maxim);
}
}
int main() {
ios::sync_with_stdio(false), fin.tie(nullptr);
int N, M; fin >> N >> M;
tree.resize(4 * N);
for (int i = 0; i < N; ++i) {
int x; fin >> x;
update(i, 1, 0, N - 1, x);
}
while(M--) {
int cer, a, b; fin >> cer >> a >> b;
if (cer == 1) {
--a;
update(a, 1, 0, N - 1, b);
} else {
int maxim = -1;
--a, --b;
query(1, a, b, 0, N - 1, maxim);
fout << maxim << '\n';
}
}
return 0;
}