#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int stree[400000], v[100000]; // segment tree
void constructST(int i, int st, int dr, int poz, int val) {
if (st == dr) {
stree[i] = val; // la nodul i pun valoarea data
return;
}
int mij = (st + dr) / 2;
if (poz <= mij) // aleg subarborele in care sa caut pozitia la care sa inserez valoarea data
constructST (2*i, st, mij, poz, val); // fiul stang
else constructST (2*i+1, mij + 1, dr, poz, val); // fiul drept
stree[i] = max( stree[2*i], stree[2 * i + 1] ); // in nod se alege maximul dintre cei 2 fii
}
int getMaxPeInterval(int i, int st, int dr, int x, int y)
{
// If segment of this node is a part of the given range, then return the min of the segment
if (x <= st && y >= dr)
return stree[i];
// If a part of this segment overlaps with the given range
int mij = st + (dr - st) / 2;
if (x > mij)
return getMaxPeInterval(2*i+1, mij + 1, dr, x, y);
else if (y <= mij)
return getMaxPeInterval(2*i, st, mij, x, y);
return max( getMaxPeInterval(2*i, st, mij, x, mij), getMaxPeInterval(2*i+1, mij+1, dr, mij+1, y) );
}
int main()
{
int n, m, a, b, op, val;
fin >> n >> m;
for (int i = 1 ; i <= n ; i++) {
fin >> val;
constructST(1, 1, n, i, val); // construiesc arborele de intervale incepand cu nodul 1, pentru intervalul [1,n], punand la pozitia i valoarea citita
}
for (int i = 0 ; i < m ; i++)
{
fin >> op >> a >> b;
if(op == 0)
fout << getMaxPeInterval(1, 1, n, a, b) << '\n';
else // op ==1 => pe pozitia a pun valoarea lui b
constructST(1, 1, n, a, b); // deci construiesc arborele de la 1 la n, punand b la poz a
}
return 0;
}