#include <fstream>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#define min(a,b) ((a<b)?a:b)
#define max(a,b) ((a<b)?b:a)
#define abs(a) ((a<0)?-a:a)
#define REP(i,a,b) \
for (int i=a; i<=b; i++)
#define INF 10000000000001
using namespace std;
//#define TEST
#ifdef TEST
ifstream fin("input.txt");
ofstream fout("output.txt");
#else
ifstream fin("arbint.in");
ofstream fout("arbint.out");
#endif // TEST
#define MAXN 1000000
#define pb push_back
#define mp make_pair
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> pp;
int n,m;
int btree[263000];
int mm=0;
void query(int code, int l, int r, int ll, int rr)
{
if (l>rr) return ;
if (r<ll) return ;
if (l>r) return ;
if (l>=ll && r<=rr) mm = max(mm, btree[code]);
else
{
query(code*2,l,(l+r)/2,ll,rr);
query(code*2+1,(l+r)/2+1,r,ll,rr);
}
}
void update(int code, int l, int r, int id, int key)
{
if (l>id) return;
if (r<id) return;
if (l>r) return;
if (l==r)
{
btree[code]=key;
} else
{
update(code*2,l,(l+r)/2,id,key);
update(code*2+1,(l+r)/2+1,r,id,key);
btree[code] = max(btree[code*2],btree[code*2+1]);
}
}
int main()
{
fin>>n>>m;
for (int i=0; i<n; i++)
{
int a;
fin>>a;
update(1,0,n-1,i,a);
}
for (int i=0; i<m; i++)
{
int x,y,z;
fin>>x>>y>>z;
if (x)
{
update(1,0,n-1,y-1,z);
} else
{
mm=0;
query(1,0,n-1,y-1,z-1);
fout<<mm;
fout<<'\n';
}
}
return 0;
}