#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
#define pb push_back
#define sz size()
#define SORT(x) sort(x.begin(), x.end())
#define REVERSE(x) reverse(x.begin(), x.end())
#define REP(x, hi) for (int x=0; x<(hi); x++)
#define FOR(x, lo, hi) for (int x=(lo); x<(hi); x++)
#define FORALL(it,x) for (typeof(x.begin()) it=x.begin(); it!=x.end(); it++)
#define INFILE "arbint.in"
#define OUTFILE "arbint.out"
ifstream fin (INFILE);
ofstream fout (OUTFILE);
#define VMAX 270000
int v[VMAX];
void add(int idx, int st, int dr, int pos, int nr)
{
if( st==dr ) v[idx] = nr;
else
{
int mij = (st+dr)/2;
if( pos<=mij ) add( (idx+1)*2-1, st, mij, pos, nr);
else add( (idx+1)*2, mij+1, dr, pos, nr);
v[idx] = max(v[(idx+1)*2-1], v[(idx+1)*2]);
}
}
int getmax(int idx, int st, int dr, int a, int b)
{
if(a<=st && dr<=b ) return v[idx];
else
{
int mij = (st+dr)/2;
if( b<=mij ) return getmax( (idx+1)*2-1, st, mij, a, b);
else if( a>mij ) return getmax( (idx+1)*2, mij+1, dr, a, b);
else return max( getmax( (idx+1)*2-1, st, mij, a, mij),
getmax( (idx+1)*2, mij+1, dr, mij+1, b));
}
}
int main()
{
memset(v, 0, sizeof(v));
int ops, op, a, b, n;
fin >> n >> ops;
REP(i, n)
{
int nr;
fin >> nr;
add(0, 0, n-1, i, nr);
}
REP(i, ops)
{
fin >> op >> a >> b;
switch(op) {
case 0:
fout << getmax(0, 0, n-1, a-1, b-1) << endl;
break;
default:
add(0, 0, n-1, a-1, b);
}
}
return 0;
}