#include<cstdio>
int arbMax[400100];
int maxim;
int maxx(int x, int y)
{if(x >= y)
return x;
return y;
}
void update(int nod, int nodSt, int nodDr, int updPos, int updVal)
{if(nodSt == nodDr)
arbMax[nod] = updVal;
else
{int m = (nodSt + nodDr) / 2;
if(updPos <= m)
update(2 * nod, nodSt, m, updPos, updVal);
else
update(2 * nod + 1, m + 1, nodDr, updPos, updVal);
arbMax[nod] = maxx(arbMax[2 * nod], arbMax[2 * nod + 1]);
}
}
void query(int nod, int nodSt, int nodDr, int updSt, int updDr)
{if(nodSt >= updSt && nodDr <= updDr)
maxim = maxx(maxim, arbMax[nod]);
else
{int m = (nodSt + nodDr) / 2;
if(updSt <= m)
query(2 * nod, nodSt, m, updSt, updDr);
if(updDr >= m + 1)
query(2 * nod + 1, m + 1, nodDr, updSt, updDr);
}
}
int main ()
{freopen ("arbint.in","r",stdin);
freopen ("arbint.out","w",stdout);
int n,m,c,x,y,i;
scanf("%d%d",&n,&m);
for(i = 1; i <= n; i++)
{scanf("%d",&x);
update(1, 1, n, i, x);
}
for(i = 1; i <= m; i++)
{scanf("%d%d%d",&c,&x,&y);
if(c == 1)
update(1, 1, n, x, y);
else
{maxim = -1;
query(1, 1, n, x, y);
printf("%d\n",maxim);
}
}
return 0;
}