#include <fstream>
using namespace std;
int st[400005];
void update(int node, int from, int to, int pos, int val)
{
if(from==to)
{
st[node]=val;
return;
}
int mid=(from+to)/2;
if(pos<=mid)
update(node*2, from, mid, pos, val);
else
update(node*2+1, mid+1, to, pos, val);
st[node]=max(st[node*2], st[node*2+1]);
}
int query(int node, int from, int to, int qleft, int qright)
{
int smax=0;
if(qleft<=from && to<=qright)
return st[node];
int mid=(from+to)/2;
if(qleft<=mid){
int s=query(node*2, from, mid, qleft, qright);
smax=max(s, smax);
}
if(mid+1<=qright){
int s=query(node*2+1, mid+1, to, qleft, qright);
smax=max(s, smax);
}
return smax;
}
int main()
{
ifstream cin("arbint.in");
ofstream cout("arbint.out");
int n, m, a, b; bool c;
cin >> n >> m;
for(int i=1; i<=n; i++)
{
cin >> a;
update(1, 1, n, i, a);
}
for(int i=1; i<=m; i++)
{
cin >> c >> a >> b;
if(c==0) cout << query(1, 1, n, a, b) << '\n';
else update(1, 1, n, a, b);
}
return 0;
}