#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
struct tree{
long long s[100000];
long long nodes[400000];
int n;
void update(int ind, int l, int r, int i){
if(l==r)
{
nodes[ind] = s[i];
cout<<nodes[ind]<<" ";
return;
}
int mij = (l+r)/2;
if(i<=mij)
update(ind*2, l, mij, i);
else
update(ind*2+1, mij+1, r, i);
nodes[ind]=max(nodes[ind*2], nodes[ind*2+1]);
cout<<nodes[ind]<<" ";
}
int query(int ind, int l, int r, int a, int b){
if(l>=a && r<=b){
return nodes[ind];
}
int mij = (l+r)/2;
int rl=-1, rr=-1;
if(a<=mij)
rl=query(ind*2, l, mij, a, b);
if(b>mij)
rr=query(ind*2+1, mij+1, r, a, b);
return max(rl, rr);
}
} tr;
int main()
{
int m, op, a, b;
fin>>tr.n>>m;
for(int i=1; i<=tr.n; i++)
{
fin>>tr.s[i];
tr.update(1, 1, tr.n, i);
}
for(int i=0; i<m; i++){
fin>>op>>a>>b;
if(op==0)
fout<<tr.query(1, 1, tr.n, a, b)<<'\n';
else
{
tr.s[a]=b;
tr.update(1, 1, tr.n, a);
}
}
return 0;
}