#include <fstream>
#define max(a, b) (a > b) ? a : b
int tree[500000];
void update(int node, int l, int r, int a, int b);
int query(int node, int l, int r, int a, int b);
int main()
{
std::ifstream in("arbint.in");
std::ofstream out("arbint.out");
int nV, nO, op, a, b;
in >> nV >> nO;
for(int i = 1; i <= nV; i++)
in >> b, update(1, 1, nV, i, b);
for(int i = 0; i < nO; i++)
{
in >> op >> a >> b;
if(op) update(1, 1, nV, a, b);
else out << query(1, 1, nV, a, b) << '\n';
}
return 0;
}
void update(int node, int l, int r, int a, int b)
{
if(l == r)
{
tree[node] = b;
return;
}
int m = (l + r) / 2;
if(a <= m)
update(2 * node, l, m, a, b);
else
update(2 * node + 1, m + 1, r, a, b);
tree[node] = max(tree[2 * node], tree[2 * node + 1]);
}
int query(int node, int l, int r, int a, int b)
{
if(a <= l && r <= b)
return tree[node];
int max1 = -1, max2 = -1, m = (l + r) / 2;
if(a <= m) max1 = query(node * 2, l, m, a, b);
if(b >= m) max2 = query(node * 2 + 1, m + 1, r, a, b);
return max(max1, max2);
}