#include <fstream>
#include <iostream>
#include <vector>
#include <bitset>
#include <string.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <deque>
using namespace std;
const char infile[] = "arbint.in";
const char outfile[] = "arbint.out";
ifstream fin(infile);
ofstream fout(outfile);
const int MAXN = 100005;
const int oo = 0x3f3f3f3f;
typedef vector<int> Graph[MAXN];
typedef vector<int> :: iterator It;
const inline int min(const int &a, const int &b) { if( a > b ) return b; return a; }
const inline int max(const int &a, const int &b) { if( a < b ) return b; return a; }
const inline void Get_min(int &a, const int b) { if( a > b ) a = b; }
const inline void Get_max(int &a, const int b) { if( a < b ) a = b; }
class SegmentTree {
private:
int N;
vector <int> arb;
int *values;
public:
SegmentTree() {
}
SegmentTree(int _N) {
N = _N;
arb.resize(N << 2);
}
SegmentTree(int _N, int *a) {
N = _N;
arb.resize(N << 2);
values = a;
Build(1, 1, N);
}
void Build(int Node, int st, int dr) {
if(st == dr) {
arb[Node] = *(values + st);
return;
}
int mid = ((st + dr) >> 1);
Build(Node << 1, st, mid);
Build((Node << 1) | 1, mid + 1, dr);
arb[Node] = max(arb[Node << 1], arb[(Node << 1) | 1]);
}
void Update(int Node, int st, int dr, int pos, int value) {
if(st == dr) {
arb[Node] = value;
return;
}
int mid = ((st + dr) >> 1);
if(pos <= mid)
Update(Node << 1, st, mid, pos, value);
else
Update((Node << 1) | 1, mid + 1, dr, pos, value);
arb[Node] = max(arb[Node << 1], arb[(Node << 1) | 1]);
}
int Query(int Node, int st, int dr, int x, int y) {
if(x <= st && dr <= y)
return arb[Node];
int mid = ((st + dr ) >> 1);
int ans = -oo;
if(x <= mid)
ans = max(ans, Query(Node << 1, st, mid, x, y));
if(mid < y)
ans = max(ans, Query((Node << 1) | 1, mid + 1, dr, x, y));
return ans;
}
};
int N, a[MAXN], M;
int main() {
cin.sync_with_stdio(false);
#ifndef ONLINE_JUDGE
freopen(infile, "r", stdin);
freopen(outfile, "w", stdout);
#endif
fin >> N >> M;
for(int i = 1 ; i <= N ; ++ i)
fin >> a[i];
SegmentTree Arb(N, a);
for(int i = 1 ; i <= M ; ++ i) {
int op, x, y;
fin >> op >> x >> y;
if(op == 0)
fout << Arb.Query(1, 1, N, x, y) << '\n';
else
Arb.Update(1, 1, N, x, y);
}
fin.close();
fout.close();
return 0;
}