//
// main.cpp
// C++ - teste
//
// Created by Filip Cuciuc on 03/02/2020.
// Copyright © 2020 Filip Cuciuc. All rights reserved.
//
//#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <map>
#include <string>
#include <cctype>
#include <iomanip>
//#include "MED.h"
using namespace std;
//using namespace std::chrono;
ifstream cin("arbore.in");
ofstream cout("arbore.out");
const int MAXN = 1e5 + 10;
int n, m;
int v[MAXN], tree[4 * MAXN];
void update(int nod, int s, int d, int poz, int val) {
if (s == d){
tree[nod] = val;
return;
}
int mij = s + d;
mij /= 2;
if (poz <= mij){
update (nod * 2 , s , mij , poz , val);
}
else{
update (nod * 2 + 1 , mij + 1 , d , poz , val);
}
tree[nod] = max(tree[nod * 2] , tree[nod * 2 + 1]);
}
int query (int nod , int s , int d , int S , int D){
if (s >= S && d <= D){
return tree[nod];
}
int mij = s + d;
mij /= 2;
int MAX = 0;
if (S <= mij){
MAX = max(MAX , query (nod * 2 , s , mij , S , D));
}
if (mij < D){
MAX = max(MAX , query (nod * 2 + 1 , mij + 1 , d , S , D));
}
return MAX;
}
void read() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> v[i];
update (1 , 1 , n , i , v[i]);
}
cout << endl;
}
void solve() {
read();
for (int i = 1; i <= m; i++){
int op , a , b;
cin >> op >> a >> b;
if (op == 1){
update (1 , 1 , n , a , b);
}
else{
cout << query(1 , 1 , n , a , b) << '\n';
}
}
}
int main() {
solve();
return 0;
}