/*
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;
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;
Update(2*node+1,mid+1,right,pos,value);
Update(2*node,left,mid,pos,value);
ST[node] = max(ST[2*node],ST[2*node+1]);
}
int Query(int node,int left, int right, int a, int b)
{
if(a <= left && right <= b)
return ST[node];
else
{
int mid = (left+right)/2;
int lson = 2*node;
int rson = lson +1;
int st,dr;
if(a <= mid)
st = Query(lson,left,mid,a,b);
if(mid <= b)
dr = Query(rson,mid+1,right,a,b);
return max(st,dr);
}
}
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
g << Query(1,1,n,x,y) << '\n';
}
}
int main()
{
Solve();
return 0;
}