#include <bits/stdc++.h>
#define pb push_back
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
typedef pair<int,int> pii;
typedef long long int ll;
typedef long double ld;
const int DMAX = 1e5+10;
int V[DMAX];
int tree[4*DMAX];
int n,m;
void build(int node,int st,int dr);
void update(int node,int st,int dr,int pos,int val);
int query(int node,int st,int dr,int x,int y);
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int t,i,j;
int x,y,z;
fin>>n>>m;
for(i=1;i<=n;i++)
fin>>V[i];
build(1,1,n);
while(m--){
fin>>x>>y>>z;
if(x & 1)
update(1,1,n,y,z);
else
fout<<query(1,1,n,y,z)<<'\n';
}
return 0;
}
void build(int node,int st,int dr){
if(st == dr){
tree[node]=V[st];
return;
}
int mij=(st+dr)/2;
build(2*node,st,mij);
build(2*node+1,mij+1,dr);
tree[node]=max(tree[2*node],tree[2*node+1]);
}
void update(int node,int st,int dr,int pos,int val){
if(st == dr){
tree[node]=val;
return;
}
int mij=(st+dr)/2;
if(pos <= mij)
update(2*node,st,mij,pos,val);
else
update(2*node+1,mij+1,dr,pos,val);
tree[node]=max(tree[2*node],tree[2*node+1]);
}
int query(int node,int st,int dr,int x,int y){
if(x <= st && dr <= y)
return tree[node];
int mij=(st+dr)/2;
int ans=0;
if(x <= mij)
ans=query(2*node,st,mij,x,y);
if(y > mij)
ans=max(ans,query(2*node+1,mij+1,dr,x,y));
return ans;
}