#include <fstream>
using namespace std;
ifstream cin ("arbint.in");
ofstream cout ("arbint.out");
const int N_MAX = 100005;
int n, q;
int aib[4 * N_MAX], v[N_MAX];
void build(int nod, int st, int dr)
{
if (st == dr)
{
aib[nod] = v[st];
return;
}
int m = (st + dr) / 2;
build(2 * nod, st, m);
build(2 * nod + 1, m + 1, dr);
aib[nod] = max(aib[nod * 2], aib[nod * 2 + 1]);
}
void update (int nod, int st, int dr, int poz, int val)
{
if (st == dr)
{
aib[nod] = val;
return;
}
int m = (st + dr) / 2;
if (poz <= m)
update (nod * 2, st, m, poz, val);
else
update (nod * 2 + 1, m + 1, dr, poz, val);
aib[nod] = max(aib[nod * 2], aib[nod * 2 + 1]);
}
int query (int nod, int st, int dr, int qst, int qdr)
{
if (st == qst && dr == qdr)
return aib[nod];
int m = (st + dr) / 2;
int a = 0, b = 0;
if (qst <= m)
a = query (nod * 2, st, m, qst, min(m, qdr));
if (m + 1 <= qdr)
b = query (nod * 2 + 1, m + 1, dr, max(m + 1, qst), qdr);
return max(a, b);
}
int main()
{
cin >> n >> q;
for (int i = 1; i <= n; i++)
cin >> v[i];
build (1, 1, n);
while (q--)
{
int tip, a, b;
cin >> tip >> a >> b;
if (tip == 0)
cout << query (1, 1, n, a, b) << "\n";
else
update(1, 1, n, a, b);
}
cout << "\n";
return 0;
}