#include <bits/stdc++.h>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n, q, a[100006], aint[400006];
void Citire()
{
fin >> n >> q;
for(int i = 1; i <= n; i++) fin >> a[i];
}
void Build(int nod, int x, int y)
{
if(x == y)
{
aint[nod] = a[x];
return;
}
int mij = (x + y) / 2;
Build(2 * nod, x, mij); ///Parcurgere subarbore stang
Build(2 * nod + 1, mij + 1, y); ///Parcurgere subarbore drept
aint[nod] = max(aint[2 * nod], aint[2 * nod + 1]);
///Actualizare valoare maxima
}
void U(int nod, int x, int y, int D, int V)
{
if(x == y)
{
aint[nod] = V;
return;
}
int mij = (x + y) / 2;
if(D <= mij)
U(2 * nod, x, mij, D, V);
else U(2 * nod + 1, mij + 1, y, D, V);
aint[nod] = max(aint[2 * nod], aint[2 * nod + 1]);
}
int Q(int nod, int x, int y, int a, int b)
{
if(x == a && y == b)
return aint[nod];
int mij = (x + y) / 2;
if(b <= mij)
return Q(2 * nod, x, mij, a, b);
else if(a > mij)
return Q(2 * nod + 1, mij + 1, y, a, b);
else return max(Q(2 * nod, x, mij, a, mij), Q(2 * nod + 1, mij + 1, y, mij + 1, b));
}
int main()
{
int op, a, b;
Citire();
Build(1, 1, n);
while(q--)
{
fin >> op >> a >> b;
if(op == 1)
U(1, 1, n, a, b);
else fout << Q(1, 1, n, a, b) << "\n";
}
return 0;
}