#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
#define INT_MAX 2147483647;
int v[400040];
void update(int nod, int st, int dr, int pos, int val)
{
if (st == dr)
{
v[nod] = val;
}
else
{
int mij = (st + dr) / 2;
if (mij >= pos)
update(nod * 2, st, mij, pos, val);
else
update(nod * 2 + 1, mij + 1, dr, pos, val);
v[nod] = max(v[nod * 2], v[nod * 2 + 1]);
}
}
int call(int nod, int st, int dr, int a, int b) {
if (a <= st && dr <= b) {
return v[nod];
}
else {
int mij = (st + dr) / 2,
min_st = 0,
min_dr = 0;
if (mij >= a)
min_st = call(nod * 2, st, mij, a, b);
if (mij + 1 <= b)
min_dr = call(nod * 2 + 1, mij + 1, dr, a, b);
return max(min_st, min_dr);
}
}
int main()
{
int n, m, x, c, a, b;
ifstream f("arbint.in");
ofstream g("arbint.out");
f >> n >> m;
for (int i = 1; i <= n; ++i) {
f >> x;
update(1, 1, n, i, x);
}
for (int i = 1; i <= m; ++i)
{
f >> c >> a >> b;
if (c == 0) {
g << call(1, 1, n, a, b) << '\n';
}
else
update(1, 1, n, a, b);
}
return 0;
}