#include <cstdio>
#include<algorithm>
#define infile "arbint.in"
#define outfile "arbint.out"
#define INF 1<<30
#define n_max 100005
using namespace std;
int AI[2*n_max];
int N, M;
void update(int nod, int st, int dr, int poz, int x)
{
if(st == dr)
{
AI[nod] = x;
return;
}
int mij = st + (dr - st)/2;
if(poz <= mij)
update(2*nod, st, mij, poz, x);
else
update(2*nod+1, mij+1, dr, poz, x);
AI[nod] = max( AI[2*nod], AI[2*nod+1]);
}
void query(int nod, int st, int dr, int a, int b, int &rez)
{
if(a<=st && dr<=b)
{
rez = max(rez, AI[nod]);
return;
}
int mij = st + (dr - st)/2;
if(a <= mij)
query(2*nod, st, mij, a, b, rez);
if(mij < b)
query(2*nod+1, mij+1, dr, a, b, rez);
}
int main()
{
freopen(infile, "r", stdin);
freopen(outfile, "w", stdout);
int Max, x, y, z;
scanf("%d %d", &N, &M);
for(int i=1;i<=N;i++)
{
scanf("%d",&x);
update(1, 1, N, i, x);
}
while(M--)
{
scanf("%d %d %d", &x, &y, &z);
if(!x)
{
query(1, 1, N, y, z, Max = -1);
printf("%d\n", Max);
}
else
update(1, 1, N, y, z);
}
fclose(stdin);
fclose(stdout);
return 0;
}