/*
Keep It Simple!
*/
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<stdio.h>
#define MaxN 100005
#define MaxV(a,b) ((a)>(b)?(a):(b))
int ArbInt[4*MaxN], N, x, M, type, a, b, maxvalue;
void UpdateAibInt(int value, int position,int left,int right,int location)
{
if (left == right)
{
ArbInt[location] = value;
}
else
{
int mid = (left + right) / 2;
if (position <= mid) UpdateAibInt(value, position, left, mid, location * 2);
else UpdateAibInt(value, position, mid + 1, right, location * 2 + 1);
ArbInt[location] = MaxV(ArbInt[2 * location], ArbInt[2 * location + 1]);
}
}
void QueryAib(int a, int b, int left, int right, int location)
{
if (a <= left && right <= b)
{
if (ArbInt[location] > maxvalue) maxvalue = ArbInt[location];
return;
}
else
{
int mid = (left + right) / 2;
if (a <= mid) QueryAib(a, b, left, mid, location * 2);
if( b > mid ) QueryAib(a, b, mid + 1, right, location * 2 + 1);
}
}
int main()
{
freopen("arbint.in", "r", stdin);
freopen("arbint.out", "w", stdout);
scanf("%d%d", &N, &M);
for (int i = 1; i <= N; i++)
{
scanf("%d", &x);
UpdateAibInt(x,i,1,N,1);
}
for (int i = 1; i <= M; i++)
{
scanf("%d%d%d", &type, &a, &b);
if (type == 1)
UpdateAibInt(b, a, 1, N, 1);
else
{
maxvalue = -3;
QueryAib(a, b, 1, N, 1);
printf("%d\n", maxvalue);
}
}
}