#include <bits/stdc++.h>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int v[100001],n,m,ST[400004];
int BuildTree(int st, int dr, int node)
{
if(st==dr) {ST[node]=v[st];return ST[node];}
else
{
int m=(st+dr)/2;
ST[node]=max(BuildTree(st,m,2*node),BuildTree(m+1,dr, 2*node+1));
return ST[node];
}
}
int GetValue(int st, int dr, int nowst, int nowdr,int node)
{
if(nowst>dr || nowdr<st) return 0;
int m=(nowst+nowdr)/2;
if(nowst>=st && nowdr<=dr) return ST[node];
else
if(m<=dr && m>=st) return max(GetValue(st,dr,nowst,m,2*node),GetValue(st,dr,m+1,nowdr,2*node+1));
else if(m>=dr) return GetValue(st,dr,nowst,m,2*node);
else if(m<=st) return GetValue(st,dr,m+1,nowdr,2*node+1);
}
int UpdateValue(int nowst, int nowdr, int node, int pos,int value)
{
if(nowst ==nowdr && nowst==pos) {ST[node]=value;v[pos]=value; return 0;}
else if(nowdr>=pos && nowst<=pos) {
int m=(nowst+nowdr)/2;
if(m>=pos) UpdateValue(nowst,m,2*node,pos,value);
else UpdateValue(m+1,nowdr,2*node+1,pos,value);
ST[node]=max(ST[2*node],ST[2*node+1]);}
}
int main()
{
int i,a,b,c,j;
f>>n>>m;
for(i=1;i<=n;i++)
f>>v[i];
BuildTree(1,n,1);
for(j=1;j<=m;j++)
{
f>>c>>a>>b;
if(c==0) g<<GetValue(a,b,1,n,1)<<"\n";
else UpdateValue(1,n,1,a,b);
}
}