#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
const int MaxN = 100010;
int arb[4 * MaxN + 10];
int n, m, Max, x, y, t;
void update(int node, int left, int right, int a, int b);
void query(int node, int left, int right, int a, int b);
int main()
{
fin >> n >> m;
for (int i = 1; i <= n; i++)
{
fin >> x;
update(1, 1, n, i, x);
}
for (int i = 1; i <= m; i++)
{
fin >> t >> x >> y;
if ( !t )
{
Max = -1;
query(1, 1, n, x, y);
fout << Max << '\n';
}
else
update(1, 1, n, x, y);
}
fin.close();
fout.close();
}
void query(int node, int left, int right, int a, int b)
{
if (a <= left && right <= b)
{
Max = max(Max, arb[node]);
return;
}
int mid = (left + right) / 2;
if (a <= mid)
query(2 * node, left, mid, a, b);
if (b > mid)
query(2 * node + 1, mid + 1, right, a, b);
}
void update(int node, int left, int right, int a, int b)
{
if (left == right)
{
arb[node] = b;
return;
}
int mid = (left + right) / 2;
if (a <= mid)
update(2 * node, left, mid, a, b);
else
update(2 * node + 1, mid + 1, right, a, b);
arb[node] = max(arb[2 * node], arb[2 * node + 1]);
}