#include <iostream>
#include <fstream>
#include <cstring>
#include <algorithm>
#define NMAX 100005
using namespace std;
//int poz, val;
int tree[NMAX << 2];
void Update(int node, int st, int dr, int poz, int val)
{
if (st >= dr)
{
tree[node] = val;
return;
}
int mij = st + ((dr - st) >> 1);
if (poz <= mij)
Update(2 * node, st, mij, poz, val);
else
Update(2 * node + 1, mij + 1, dr, poz, val);
tree[node] = max(tree[2 * node], tree[2 * node + 1]);
}
int Query(int node, int st, int dr, int a, int b)
{
if (a <= st && dr <= b) return tree[node];
int mij = st + ((dr - st) >> 1);
int resLeft = 0, resRight = 0;
if (a <= mij) resLeft = Query(2 * node, st, mij, a, b);
if (b > mij) resRight = Query(2 * node + 1, mij + 1, dr, a, b);
return max(resLeft, resRight);
}
int main()
{
//memset(tree, 0, sizeof(tree));
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n, m;
fin >> n >> m;
for (int i = 1; i <= n; ++i)
{
int x;
fin >> x;
Update(1, 1, n, i, x);
}
for (int i = 1; i <= m; ++i)
{
int t, a, b;
fin >> t >> a >> b;
if (t == 0)
fout << Query(1, 1, n, a, b) << '\n';
else
Update(1, 1, n, a, b);
}
return 0;
}