#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 = 100001;
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; }
int arb[MAXN << 2], A[MAXN];
inline int leftSon(const int &Node) {
return Node << 1;
}
inline int rightSon(const int &Node) {
return (Node << 1) | 1;
}
void buildSegmentTree(const int &Node, const int &st, const int &dr) {
if(st == dr) {
arb[Node] = A[st];
return;
}
int mid = ((st + dr) >> 1);
buildSegmentTree(leftSon(Node), st, mid);
buildSegmentTree(rightSon(Node), mid + 1, dr);
arb[Node] = max(arb[leftSon(Node)], arb[rightSon(Node)]);
}
void UpdateSegmentTree(const int &Node, const int &st, const int &dr, const int &pos, const int &value) {
if(st == dr) {
arb[Node] = value;
return;
}
int mid = ((st + dr) >> 1);
if(pos <= mid)
UpdateSegmentTree(leftSon(Node), st, mid, pos, value);
else UpdateSegmentTree(rightSon(Node), mid + 1, dr, pos, value);
arb[Node] = max(arb[leftSon(Node)], arb[rightSon(Node)]);
}
int QuerySegmentTree(const int &Node, const int &st, const int &dr, const int &x, const int &y) {
if(x <= st && dr <= y)
return arb[Node];
int mid = ((st + dr)>>1);
int ret = 0;
if(x <= mid)
ret = max(ret, QuerySegmentTree(leftSon(Node), st, mid, x, y));
if(mid < y)
ret= max(ret, QuerySegmentTree(rightSon(Node), mid + 1, dr, x, y));
return ret;
}
int main() {
int N, M;
fin >> N >> M;
for(int i = 1 ; i <= N ; ++ i)
fin >> A[i];
buildSegmentTree(1, 1, N);
for(int i = 1 ; i <= M ; ++ i) {
int op, x, y;
fin >> op >> x >> y;
if(op)
UpdateSegmentTree(1, 1, N, x, y);
else fout << QuerySegmentTree(1, 1, N, x, y) << '\n';
}
fin.close();
fout.close();
return 0;
}