#include <cstdio>
#include <vector>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef vector< vi > vii;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int, int> ii;
#define PB push_back
#define SZ(v) v.size()
#define ALL(v) (v).begin(), (v).end()
#define FORIT(i,c) for (typeof((c).end()) i=(c).begin(); i!=(c).end(); ++i)
#define FOR(i,n) for (int i = 0; i<(n); ++i)
#define FORE(i,n) for (int i = 0; i<=(n); ++i)
#define FORI(i,n1,n2) for (int i = n1; i<(n2); ++i)
#define FORIE(i,n1,n2) for (int i = n1; i<=(n2); ++i)
#define FORV(i,v) for (unsigned int i = 0; i<SZ(v); ++i)
#define INF 0x3f3f3f3f
#define EPS 1e-9
#define NMAX 100001
int N,M;
int A[NMAX*3];
int st, dr, pos, val;
int query(int nod, int nod_st, int nod_dr)
{
if (st<=nod_st && nod_dr<=dr)
return A[nod];
else
{
int x1 = 0, x2 = 0;
int mid = (nod_st + nod_dr) / 2;
if (st<=mid)
x1 = query(nod*2, nod_st, mid);
if (dr>=mid+1)
x2 = query(nod*2+1, mid+1, nod_dr);
return max(x1, x2);
}
}
void update(int nod, int nod_st, int nod_dr)
{
if (nod_st < nod_dr)
{
int mid = (nod_st+nod_dr)/2;
if (pos<=mid)
update(nod*2, nod_st, mid);
else
update(nod*2+1, mid+1, nod_dr);
A[nod] = max(A[nod*2], A[nod*2+1]);
}
else
{
A[nod] = val;
}
}
int main()
{
freopen("arbint.in", "r", stdin);
freopen("arbint.out", "w", stdout);
scanf("%d %d", &N, &M);
FOR(i, N)
{
int x;
scanf("%d", &x);
pos = i+1;
val = x;
update(1, 1, N);
}
FOR(i, M)
{
int o, x, y;
scanf("%d %d %d", &o, &x, &y);
if (o == 0)
{
st = x;
dr = y;
printf("%d\n", query(1, 1, N));
}
else
{
pos = x;
val = y;
update(1, 1, N);
}
}
return 0;
}