//#include "pch.h"
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n, m, ans;
int aint[400005];
void update(int left, int right, int value, int position, int node) {
if (left == right) {
aint[node] = value;
return;
}
int middle = left + (right - left) / 2;
if (position <= middle) {
update(left, middle, value, position, 2 * node);
}
else {
update(middle + 1, right, value, position, 2 * node + 1);
}
aint[node] = max(aint[2 * node], aint[2 * node + 1]);
}
int query(int node, int left, int right, int a, int b) {
if (left >= a && b >= right) {
return aint[node];
}
int middle = left + (right - left) / 2;
if (middle >= a) {
ans = max(query(2 * node, left, middle, a, b), ans);
}
if (middle < b) {
ans = max(query(2 * node + 1, middle + 1, right, a, b), ans);
}
return ans;
}
int main()
{
ios::sync_with_stdio(false);
fin.tie(0); fout.tie(0);
fin >> n >> m;
for (int i = 1; i <= n; ++i) {
int x;
fin >> x;
update(1, n, x, i, 1);
}
for (int i = 1; i <= m; ++i) {
int x, a, b;
fin >> x >> a >> b;
if (x == 0) {
fout << query(1, 1, n, a, b) << '\n';
ans = 0;
}
else {
update(1, n, b, a, 1);
}
}
}