/*
Keep It Simple!
*/
#include <fstream>
#include <vector>
#include <list>
#include <stack>
#include <string>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int kMaxN = 100005;
int n,m,x,y,tip,ans;
int ST[4*kMaxN];
void Update(int node,int left,int right,int pos, int value)
{
if(left == right)
{
ST[node] = value;
return;
}
int mid = (left+right)/2;
if(pos > mid)
Update(2*node+1,mid+1,right,pos,value);
else
Update(2*node,left,mid,pos,value);
ST[node] = max(ST[2*node],ST[2*node+1]);
}
void Query(int node,int left, int right, int a, int b)
{
if(a <= left && right <= b)
{
ans = max(ST[node],ans);
return;
}
else
{
int mid = (left+right)/2;
int lson = 2*node;
int rson = lson +1;
if(a <= mid)
Query(lson,left,mid,a,b);
if(mid < b)
Query(rson,mid+1,right,a,b);
}
}
void Solve()
{
f >> n >> m;
for(int i=1;i<=n;++i)
{
f >> x;
Update(1,1,n,i,x);
}
for(int i=1;i<=m;++i)
{
f >> tip >> x >> y;
if(tip)
Update(1,1,n,x,y);
else
{
ans = 0;
Query(1,1,n,x,y);
g << ans << '\n';
}
}
}
int main()
{
Solve();
return 0;
}