#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
const int NMax = 100002;
int n, arb[4 * NMax], q, maxx;
void Update(int node, int st, int dr, int pos, int val)
{
if(st == dr)
{
arb[node] = val;
return;
}
int m = (st + dr) >> 1;
if(m < pos) Update(2 * node + 1, m + 1, dr, pos, val);
else Update(2 * node, st, m, pos, val);
arb[node] = max(arb[2 * node], arb[2 * node + 1]);
}
void Query(int node, int st, int dr, int left, int right)
{
if(left <= st && right >= dr)
{
maxx = max(arb[node], maxx);
return;
}
int m = (st + dr) >> 1;
if(m >= left) Query(2 * node, st, m, left, right);
else if(m < right) Query(2 * node + 1, m + 1, dr, left, right);
}
int main()
{
int a, b, t, x;
f >> n >> q;
for(int i = 1; i <= n; ++i)
{
f >> x;
Update(1, 1, n, i, x);
}
for(int i = 1; i <= q; ++i)
{
f >> t >> a >> b;
if(t) Update(1, 1, n, a, b);
else
{
maxx = -1;
Query(1, 1, n, a, b);
g << maxx << '\n';
}
}
}