#include <bits/stdc++.h>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int n,m,bsize,v[100005],mx[100005];
vector<int> b[100005];
pair<int,int> get_poz(int poz)
{
return {(poz+bsize-1)/bsize,(poz-1)%bsize};
}
void update(int poz, int val)
{
pair<int,int> p = get_poz(poz);
b[p.first][p.second] = val;
mx[p.first] = 0;
for(auto it : b[p.first])
{
mx[p.first] = max(mx[p.first],it);
}
}
int query(int x, int y)
{
pair<int,int> st = get_poz(x);
pair<int,int> dr = get_poz(y);
if(st.first==dr.first)
{
int Max = 0;
for(int i=st.second;i<=dr.second;i++)
{
Max = max(Max,b[st.first][i]);
}
return Max;
}
int Max = 0;
for(int i=st.second;i<b[st.first].size();i++)
{
Max = max(Max,b[st.first][i]);
}
for(int i=st.first+1;i<dr.first;i++)
{
Max = max(Max,mx[i]);
}
for(int i=0;i<=dr.second;i++)
{
Max = max(Max,b[dr.first][i]);
}
return Max;
}
int main()
{
f>>n>>m;
bsize = sqrt(n);
for(int i=1;i<=n;i++)
{
f>>v[i];
int bucket = get_poz(i).first;
b[bucket].push_back(v[i]);
mx[bucket] = max(mx[bucket],v[i]);
}
for(int i=1;i<=m;i++)
{
int t;
f>>t;
if(t==0)
{
int a,b;
f>>a>>b;
g<<query(a,b)<<'\n';
}
else
{
int poz,val;
f>>poz>>val;
update(poz,val);
}
}
return 0;
}