#include <fstream>
#include <limits.h>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
const int NMAX = 1e5 + 1;
int st[4 * NMAX];
void update(int crtIndex, int &pos, int &val, int l, int r)
{
if (l > r)
return;
if (l == r)
{
st[crtIndex] = val;
return;
}
int mid = (l + r) / 2;
if (pos <= mid)
update(2 * crtIndex, pos, val, l, mid);
else
update(2 * crtIndex + 1, pos, val, mid + 1, r);
st[crtIndex] = max(st[2 * crtIndex], st[2 * crtIndex + 1]);
}
void query(int crtIndex, int &queryLeft, int &queryRight, int &ans, int l, int r)
{
if (queryLeft <= l && r <= queryRight)
{
ans = max(ans, st[crtIndex]);
return;
}
int m = (l + r) / 2;
if (m >= queryLeft)
query(2 * crtIndex, queryLeft, queryRight, ans, l, m);
if (m < queryRight)
query(2 * crtIndex + 1, queryLeft, queryRight, ans, m + 1, r);
}
int main()
{
int n, m, a, b, c;
fin >> n >> m;
for (int i = 1; i <= n; ++i)
{
fin >> a;
update(1, i, a, 1, n);
}
while (m--)
{
fin >> a >> b >> c;
if (a == 0)
{
int ans = INT_MIN;
query(1, b, c, ans, 1, n);
fout << ans << '\n';
}
else
update(1, b, c, 1, n);
}
return 0;
}