#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
using namespace std;
#define NM 100005
int N, M, ARB[3*NM], ans;
void update(int nod, int st, int dr, int a, int b)
{
if (st == dr)
{
ARB[nod] = b;
return ;
}
int mij = (st + dr)/2;
if (a <= mij) update (2*nod, st, mij, a, b);
else update (2*nod + 1, mij + 1, dr, a, b);
ARB[nod] = max(ARB[2*nod], ARB[2*nod+1]);
}
void query(int nod, int st, int dr, int a, int b)
{
if (a <= st && dr <= b)
{
ans = max(ans, ARB[nod]);
return ;
}
int mij = (st + dr)/2;
if (a <= mij) query(2*nod, st, mij, a, b);
if (mij + 1 <= b) query(2*nod + 1, mij+1, dr, a, b);
}
int main()
{
freopen ("aint.in", "r", stdin);
freopen ("aint.out", "w", stdout);
scanf ("%d %d", &N, &M);
for (int i = 1; i <= N; ++i)
{
int val;
scanf ("%d", &val);
update(1, 1, N, i, val);
}
while (M--)
{
int op, a, b;
scanf ("%d %d %d", &op, &a, &b);
if (op) update(1, 1, N, a, b);
else
{
ans = 0;
query(1, 1, N, a, b);
printf ("%d\n", ans);
}
}
return 0;
}