#include <iostream>
#include <fstream>
#include <algorithm>
#define NMAX 100001
using namespace std;
ifstream in("arbint.in");
ofstream out("arbint.out");
int AINT[4 * NMAX];
void Update(int node, int st, int dr, int poz, int key)
{
if (st == dr)
AINT[node] = key;
else
{
int mid = st + (dr - st) / 2;
if (poz <= mid)
Update(2 * node, st, mid, poz, key);
if (poz > mid)
Update(2 * node + 1, mid + 1, dr, poz, key);
AINT[node] = max(AINT[2 * node], AINT[2 * node + 1]);
}
}
int Query(int node, int st, int dr, int left, int right)
{
if (left <= st && dr <= right)
return AINT[node];
else
{
int mid = st + (dr - st) / 2;
int QueryL = 0, QueryR = 0;
if (left <= mid)
QueryL = Query(2 * node, st, mid, left, right);
if (right > mid)
QueryR = Query(2 * node + 1, mid + 1, dr, left, right);
return max(QueryL, QueryR);
}
}
int main()
{
int n, m;
in >> n >> m;
int x, y, z;
for (int i = 1; i <= n; i++)
{
in >> x;
Update(1, 1, n, i, x);
}
for (int i = 1; i <= m; i++)
{
in >> x >> y >> z;
if (x == 0)
out << Query(1, 1, n, y, z) << "\n";
else
Update(1, 1, n, y, z);
}
in.close();
out.close();
return 0;
}