#include <stdio.h>
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <time.h>
#include <bitset>
#include <string>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <limits.h>
#include <algorithm>
#include <deque>
#define nmax 100010
using namespace std;
int n,m,i,j,x,y,arb[nmax*3],tip;
inline int max(int a,int b) { if (a>b) return a; else return b; }
void build(int nod,int st,int dr)
{
if (st==dr) { scanf("%d",&arb[nod]); return; } else
{
int m=(st+dr)/2;
build(nod*2,st,m);
build(nod*2+1,m+1,dr);
arb[nod]=max(arb[nod*2],arb[nod*2+1]);
}
}
void update(int nod,int st,int dr)
{
if (st>=x && dr<=x) arb[nod]=y; else
{
int m=(st+dr)/2;
if (x<=m) update(nod*2,st,m); else
update(nod*2+1,m+1,dr);
arb[nod]=max(arb[nod*2],arb[nod*2+1]);
}
}
int query(int nod,int st,int dr)
{
if (st>=x && dr<=y) return arb[nod]; else
{
int m=(st+dr)/2,maxx=0;
if (x<=m) maxx=max(maxx,query(nod*2,st,m));
if (y>m) maxx=max(maxx,query(nod*2+1,m+1,dr));
return maxx;
}
}
int main(){
freopen("arbint.in","r",stdin);
freopen("arbint.out","w",stdout);
scanf("%d%d",&n,&m);
build(1,1,n);
for (i=1;i<=m;i++){
scanf("%d%d%d",&tip,&x,&y);
if (tip==0) printf("%d\n",query(1,1,n)); else
update(1,1,n);
}
return 0;
}