#include <fstream>
#include <cstdlib>
#define N_MAX 262155
using namespace std;
int aint[N_MAX];
inline int _max(int x, int y) {return x >= y ? x : y;}
inline void Update(int index, int left, int right, const int& xIndex, const int& xValue)
{
if(left == right)
aint[index]=xValue;
else {
int middle=(left+right)>>1;
if(xIndex <= middle)
Update(index<<1, left, middle, xIndex, xValue);
else Update((index<<1)|1, middle+1, right, xIndex, xValue);
aint[index]=_max(aint[index<<1], aint[(index<<1)|1]);
}
}
inline int Query(int index, int left, int right, const int& startInt, const int& endInt)
{
if(left >= startInt && right <= endInt)
return aint[index];
int middle=(left+right)>>1, m1=-1, m2=-1;
if(startInt <= middle)
m1=Query(index<<1, left, middle, startInt, endInt);
if(middle < endInt)
m2=Query((index<<1)|1, middle+1, right, startInt, endInt);
return _max(m1, m2);
}
int main()
{
int N, M, i, x, op, a, b;
ifstream in("arbint.in");
ofstream out("arbint.out");
in>>N>>M;
for(i=1; i <= N; ++i)
{
in>>x;
Update(1, 1, N, i, x);
}
for(; M; --M)
{
in>>op>>a>>b;
if(0 == op)
out<<Query(1, 1, N, a, b)<<'\n';
else Update(1, 1, N, a, b);
}
return EXIT_SUCCESS;
}