#include <iostream>
#include <stdio.h>
#include <fstream>
#include <assert.h>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
const int MAX_SIZE = 100000;
int tree[2 * MAX_SIZE], maxValue;
void update(int left, int right, int curNode, int val, int pos) {
if (left == right) {
tree[curNode] = val;
return;
}
int mid = (left + right) / 2;
if (pos <= mid) {
update(left, mid, 2 * curNode, val, pos);
} else {
update(mid + 1, right, 2 * curNode + 1, val, pos);
}
tree[curNode] = max(tree[2 * curNode], tree[2 * curNode + 1]);
}
void query(int left, int right, int start, int end, int curNode) {
if (start <= left && right <= end) {
maxValue = max(maxValue, tree[curNode]);
return;
}
int mid = (left + right) / 2;
if (start <= mid) {
query(left, mid, start, end, 2 * curNode);
}
if (end > mid) {
query(mid + 1, right, start, end, 2 * curNode + 1);
}
}
int main() {
std::ios::sync_with_stdio(false);
int n, tasks;
fin >> n >> tasks;
for (int pos = 1; pos <= n; ++pos) {
int val;
fin >> val;
update(1, n, 1, val, pos);
}
for (int i = 1; i <= tasks; ++i) {
int task;
fin >> task;
if (task == 1) {
int pos, val;
fin >> pos >> val;
update(1, n, 1, val, pos);
} else {
int start, end;
fin >> start >> end;
maxValue = -1;
query(1, n, start, end, 1);
fout << maxValue << "\n";
}
}
}