#include <fstream>
#define DIM 100010
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int a, b, n, m, i, x, p, v[4*DIM], o, s;
int maxim( int x, int y)
{
if (x >= y)
return x;
return y;
}
void update(int nod, int p, int u,int poz, int x){
if(p == u){
v[nod] = x;
return;
}
else{
int m = (p + u) / 2;
if(poz <= m)
update(2 * nod,p,m,poz,x);
if( poz > m)
update(2 * nod + 1,m + 1,n,poz,x);
v[nod]=maxim(v[2 * nod], v[2 * nod + 1]);
}
}
void query(int nod, int st, int dr, int a, int b){
if(a <= st && b >= dr){
s = maxim(v[nod],s);
return;
}
int mid = (st + dr) / 2;
if(a <= mid)
query(2 * nod, st, mid, a, b);
if( b > mid)
query(2 * nod + 1, mid + 1, dr, a, b);
}
int main()
{
fin >> n >> m;
for(i = 1; i <= n; i ++){
fin >> a;
update(1,1,n,i,a);
}
for(i = 1; i <= m; i ++){
s = 0;
fin >> o;
if(o == 1){
fin >> p >> x;
update(1,1,n,p,x);
}
else{
fin >> a >> b;
query(1,1,n,a,b);
fout << s << '\n';
}
}
return 0;
}