import java.util.*;
import java.io.*;
class Main {
static final class FastScanner {
private final byte[] buffer = new byte[1 << 16];
private int ptr = 0, len = 0;
private final InputStream in;
FastScanner(String file) throws Exception {
in = new FileInputStream(file);
}
int read() throws IOException {
if (ptr >= len) {
len = in.read(buffer);
ptr = 0;
if (len <= 0) return -1;
}
return buffer[ptr++];
}
int nextInt() throws IOException {
int c, sign = 1, val = 0;
do { c = read(); } while (c <= ' ');
if (c == '-') { sign = -1; c = read(); }
while (c > ' ') {
val = val * 10 + (c - '0');
c = read();
}
return val * sign;
}
}
static int[] v;
static class SegmentTree{
static int[] tree;
static int h(int x, int y){
return Math.max(x,y);
}
public static void set(int n){
tree = new int[v.length * 4];
build(1,1,n);
}
public static void build(int node, int l, int r){
if(l == r) tree[node] = v[l];
else{
int mid = (l+r)/2;
build(node*2, l, mid);
build(node*2+1, mid+1, r);
tree[node] = h(tree[node*2],tree[node*2+1]);
}
}
public static void update(int node, int l, int r, int poz, int val){
if(l == r) tree[node] = val;
else{
int mid = (l+r)/2;
if(poz <= mid) update(node*2,l,mid,poz,val);
else update(node*2+1,mid+1,r,poz,val);
tree[node] = h(tree[node*2],tree[node*2+1]);
}
}
public static int query(int node, int l, int r, int ql, int qr){
if(ql <= l && r <= qr) return tree[node];
else{
int mid = (l+r)/2;
int val = -1;
if(ql <= mid) val = h(val,query(node*2,l,mid,ql,qr));
if(qr > mid) val = h(val,query(node*2+1,mid+1,r,ql,qr));
return val;
}
}
}
public static void main(String[] args) throws Exception {
FastScanner fs = new FastScanner("arbint.in");
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("arbint.out")));
int n, m, op, a, b;
n = fs.nextInt();
v = new int[n+1];
m = fs.nextInt();
for(int i = 1 ; i <= n ; ++i) {
v[i] = fs.nextInt();
}
SegmentTree.set(n);
for(int i = 1 ; i <= m ; ++i){
op = fs.nextInt();
a = fs.nextInt();
b = fs.nextInt();
if(op == 0) pw.println((Segt.query(1,1,n,a,b)));
else Segt.update(1,1,n,a,b);
}
pw.close();
}
}