#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
const ll MAXN=1e7;
const ll minfinit=-1e7;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define rc(x) return cout<<x<<"\n",0
#define sz(s) (int) s.size()
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
using namespace std;
ll t[4*MAXN],m,n;
void buildSegTree(int arr[], int v, int tl, int tr) {
if (tl==tr) {
t[v]=arr[tl];
}
else {
int tm=(tl+tr)/2;
buildSegTree(arr, 2*v,tl,tm);
buildSegTree(arr,2*v+1,tm+1,tr);
t[v]=max(t[v*2],t[v*2+1]);
}
}
void changeValue(int a[], int v, int tl, int tr, int pos, int newVal) {
if (tl==tr) {
t[v]=newVal;
a[tl]=pos;
}
else {
int tm=(tl+tr)/2;
if (pos<=tm) {
changeValue(a,2*v,tl,tm,pos,newVal);
}
else {
changeValue(a,2*v+1,tm+1,tr,pos,newVal);
}
t[v]=max(t[v*2],t[v*2+1]);
}
}
int maxValue(int v, int tl, int tr, int l, int r) {
if (tr<l || tl>r) {
return minfinit;
}
else if (tl>=l && tr<=r) {
return t[v];
}
else {
ll tm=(tl+tr)/2;
return max(maxValue(2*v,tl,tm,l,r),maxValue(2*v+1,tm+1,tr,l,r));
}
}
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ifstream cin("arbint.in");
ofstream cout("arbint.out");
cin >> n >> m;
int arr[n+5];
for (int i=1; i<=n; i++) {
cin >> arr[i];
}
buildSegTree(arr,1,1,n);
while (m--) {
int cas,a,b;
cin >> cas;
if (cas) {
cin >> a >> b;
changeValue(arr,1,1,n,a,b);
}
else {
cin >> a >> b;
cout << maxValue(1,1,n,a,b) << '\n';
}
}
}