#include <bits/stdc++.h>
#define MAXN 100005
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int ait[MAXN * 4], N;
inline void Update(int poz, int ls, int ld, int p, int val)
{
if (ls == ld && ls == p)
{
ait[poz] = val;
return;
}
if (ls > p || ld < p)
return;
int mij = (ls + ld) / 2;
Update(poz * 2, ls, mij, p, val);
Update(poz * 2 + 1, mij + 1, ld, p, val);
ait[poz] = max(ait[poz * 2], ait[poz * 2 + 1]);
}
inline int Query(int poz, int ls, int ld, int st, int dr)
{
if (st <= ls && ld <= dr)
return ait[poz];
if (st > ld || dr < ls)
return 0;
int mij = (ls + ld) / 2;
int aux1 = Query(poz * 2, ls, mij, st, dr);
int aux2 = Query(poz * 2 + 1, mij + 1, ld, st, dr);
return max(aux1, aux2);
}
int main ()
{
int M, a, b, tip;
fin >> N >> M;
for (int i = 1; i <= N; i++)
{
fin >> a;
Update(1, 1, N, i, a);
}
while (M--)
{
fin >> tip >>a >> b;
if (tip == 0)
{
fout << Query(1, 1, N, a, b) << "\n";
}
else
{
Update(1, 1, N, a, b);
}
}
return 0;
}