#include <bits/stdc++.h>
#define nmax 100001
using namespace std;
int n, q, mxx;
int v[ nmax ], tree[ 4 * nmax ];
void build(int nod, int left, int right){
if (left == right){
tree[ nod ] = v[ left ];
return;
}
int mid = (left + right) / 2;
build(nod * 2, left, mid);
build(nod * 2 + 1, mid + 1, right);
tree[ nod ] = max(tree[ nod * 2 ], tree[ nod * 2 + 1 ]);
}
void update(int nod, int left, int right, int poz, int val){
if (left == right){
tree[ nod ] = val;
return;
}
int mid = (left + right) / 2;
if (poz <= mid)
update(nod * 2, left, mid, poz, val);
else
update(nod * 2 + 1, mid + 1, right, poz, val);
tree[ nod ] = max(tree[ nod * 2 ], tree[ nod * 2 + 1 ]);
}
void solve(int nod, int left, int right, int x, int y){
if (x <= left && right <= y){
mxx = max(mxx, tree[ nod ]);
return;
}
int mid = (left + right) / 2;
if (x <= mid)
solve(nod * 2, left, mid, x, y);
if (y > mid)
solve(nod * 2 + 1, mid + 1, right, x, y);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie( false );
cout.tie( false );
ifstream cin("arbint.in");
ofstream cout("arbint.out");
cin >> n >> q;
for (int i = 1; i <= n; ++i)
cin >> v[ i ];
build(1, 1, n);
for (int i = 0, x, y, z; i < q; ++i){
cin >> z >> x >> y;
if (z == 1)
update(1, 1, n, x, y);
else{
mxx = -1;
solve(1, 1, n, x, y);
cout << mxx << '\n';
}
}
}