#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0);
ifstream in("arbint.in");
ofstream out("arbint.out");
const int N = 4e5 + 17;
const int INF = 0x3f3f3f3f;
int v[N];
void update(int st, int dr, int nod, int poz, int val)
{
if(st == dr)
{
v[nod] = val;
return;
}
int mij = (st + dr) / 2;
if(poz <= mij)
update(st, mij, 2 * nod, poz, val);
else
update(mij + 1, dr, 2 * nod + 1, poz, val);
v[nod] = max(v[2 * nod], v[2 * nod + 1]);
}
int ans;
void query(int st, int dr, int nod, int a, int b)
{
if(a <= st && dr <= b)
{
ans = max(ans, v[nod]);
return;
}
int mij = (st + dr) / 2;
if(a <= mij)
query(st, mij, 2 * nod, a, b);
if(b > mij)
query(mij + 1, dr, 2 * nod + 1, a, b);
}
main()
{
int n, q;
in >> n >> q;
for(int i = 1; i <= n; i++)
{
int x;
in >> x;
update(1, n, 1, i, x);
}
while(q--)
{
int task, a, b;
in >> task >> a >> b;
if(task)
update(1, n, 1, a, b);
else
{
ans = -INF;
query(1, n, 1, a, b);
out << ans << '\n';
}
}
}