#include <bits/stdc++.h>
using namespace std;
ifstream in("arbint.in");
ofstream out("arbint.out");
int arbint[400005], n, m;
int maxi(int node_poz, int st, int dr, int a, int b)
{
if(a <= st && dr <= b)
return arbint[node_poz];
else
{
int m = (st+dr) / 2;
int son1 = -1;
int son2 = -1;
if(a <= m)
son1 = maxi(node_poz*2, st, m, a, b);
if(b > m)
son2 = maxi(node_poz*2+1, m+1, dr, a, b);
return max(son1, son2);
}
}
void f(int node_poz, int st, int dr, int poz, int x)
{
if(st == dr && dr == poz)
arbint[node_poz] = x;
else
{
int m = (st+dr) / 2;
if(poz <= m)
f(node_poz*2, st, m, poz, x);
else f(node_poz*2 + 1, m+1, dr, poz, x);
arbint[node_poz] = max(arbint[node_poz*2], arbint[node_poz*2 + 1]);
}
}
int main()
{
int a, b, x, op;
in >> n >> m;
for(int i = 1; i <= n; i++){
in >> x;
f(1, 1, n, i, x);
}
for(int i = 1; i <= m; i++){
in >> op >> a >> b;
if(op == 0)
out << maxi(1, 1, n, a, b) << '\n';
else f(1, 1, n, a, b);
}
}