// calificatClar.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <fstream>
using namespace std;
const int NMAX = 100010;
int aint[4 * NMAX + 5];
ifstream cin("arbint.in");
ofstream cout("arbint.out");
void update(int node, int l, int r, int poz, int val) {
if (l == r) {
aint[node] = val;
return;
}
int mid = (l + r) >> 1;
int stanga = node << 1;
int dreapta = stanga | 1;
if (poz <= mid) {
update(stanga, l, mid, poz, val);
}
else{
update(dreapta, mid + 1, r, poz, val);
}
aint[node] = max(aint[stanga], aint[dreapta]);
return;
}
int querry(int node, int l, int r, int lq, int rq) {
if (lq <= l && rq >= r) {
return aint[node];
}
int mid = (l + r) >> 1;
int stanga = node << 1;
int dreapta = stanga | 1;
int x = 0, y = 0;
if (mid >= lq) {
x = querry(stanga, l, mid, lq, rq);
}
if (mid + 1 <= rq) {
y = querry(dreapta, mid + 1, r, lq, rq);
}
return max(x, y);
}
int main()
{
int n, m;
cin >> n >> m;
for (int i = 1, x; i <= n; i++) {
cin >> x;
update(1, 1, n, i, x);
}
while (m--) {
int x, y, z;
cin >> x >> y >> z;
if (x == 0) {
cout << querry(1, 1, n, y, z) << endl;
}
else if (x == 1) {
update(1, 1, n, y, z);
}
}
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file