#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <iomanip>
#include <cstring>
#define NMax 500005
using namespace std;
int n,m,x,sol,q,a,b;
int ARB[NMax];
void update(int nod,int st, int dr,int poz,int val){
if(st == dr){
ARB[nod] = val;
return;
}
int m = (st + dr) / 2;
if(poz <= m)
update(2 * nod, st, m, poz, val);
else
update(2 * nod + 1, m + 1, dr, poz, val);
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 && b >= dr){
sol = max(sol, ARB[nod]);
return;
}
int m = (st + dr) / 2;
if(a <= m)
query(2 * nod, st, m, a, b);
if(m < b)
query(2 * nod + 1, m + 1, dr, a, b);
}
int main()
{
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i = 1; i <= n; ++i){
scanf("%d",&x);
update(1,1,n,i,x);
}
for(int i = 1; i <= m; ++i){
scanf("%d%d%d",&q,&a,&b);
if(q == 1)
update(1,1,n,a,b);
else{
sol = 0 ;
query(1,1,n,a,b);
printf("%d\n",sol);
}
}
return 0;
}