#include <fstream>
#include <vector>
#include <climits>
#include <cmath>
using namespace std;
ifstream fin ("arbint.in");
ofstream fout ("arbint.out");
const int NMAX = 1e6;
int v[NMAX + 5], rightmax, n;
vector <int> aint;
const int INF = INT_MAX;
void build(int node, int left = 1, int right = rightmax)
{
if(left == right and left > n)
{
aint[node] = INF;
return;
}
if(left == right)
{
aint[node] = v[left];
return;
}
int mid = (left + right) / 2;
build(2 * node, left, mid);
build(2 * node + 1, mid + 1, right);
aint[node] = max(aint[2 * node], aint[2 * node + 1]);
}
void update(int pos, int value, int node = 1, int left = 1, int right = rightmax)
{
if(left == right and left > n)
{
aint[node] = INF;
return;
}
if(left == right)
{
aint[node] = value;
return;
}
int mid = (left + right) / 2;
if(pos <= mid)
update(pos , value, 2 * node, left, mid);
else
update(pos , value, 2 * node + 1, mid + 1, right);
aint[node] = max(aint[2 * node], aint[2 * node + 1]);
}
int query(int left_int, int right_int, int node = 1, int left = 1, int right = rightmax)
{
if(left_int <= left and right <= right_int)
return aint[node];
int mid = (left + right) / 2;
int leftans = 0, rightans = 0;
if(left_int <= mid)
leftans = query(left_int, right_int, 2 * node, left, mid);
if(right_int > mid)
rightans = query(left_int, right_int, 2 * node + 1, mid + 1, right);
return max(leftans, rightans);
}
int main()
{
int m;
fin >> n >> m;
for(int i = 1; i <= n; i++)
fin >> v[i];
int exp = log2(n), nodes;
if((1 << exp) == n)
{
nodes = 2 * (1 << exp) - 1;
}
else
{
exp++;
nodes = 2 * (1 << exp) - 1;
}
aint.resize(nodes + 5);
rightmax = 1 << exp;
build(1, 1, rightmax);
for(int i = 1; i <= m; i++)
{
int op, x, y;
fin >> op >> x >> y;
if(op == 0)
fout << query(x, y) << '\n';
else if(op == 1)
update(x, y);
}
fin.close();
fout.close();
return 0;
}