#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
using namespace std;
int n, m, a, b, v[400001], c, mx, x;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
void insertX(int nr, int st, int dr, int indexx, int pozArbore)
{
int mj;
if (st == dr)
{
v[pozArbore] = nr;
return;
}
mj = (st+dr)/2;
if(mj < indexx)
insertX(nr, mj+1, dr, indexx, 2*pozArbore+1);
if(mj >= indexx)
insertX(nr, st, mj, indexx, 2*pozArbore);
v[pozArbore] = max(v[pozArbore*2+1], v[pozArbore*2]);
}
void interogare(int a, int b, int st, int dr, int pozArbore)
{
if(a <= st && b >= dr){
mx = max(v[pozArbore], mx);
return;
}
int mj = (st+dr)/2;
if(mj >= a)
interogare(a, b, st, mj, pozArbore*2);
if(mj < b)
interogare(a, b, mj+1, dr, pozArbore*2+1);
}
int main()
{
cin>>n>>m;
for(int i = 1; i<=n; i++)
{
cin>>x;
insertX(x, 1, n, i, 1);
}
for(int i = 1; i<=m; i++)
{
cin>>c>>a>>b;
if(c == 1)
insertX(b, 1, n, a, 1);
else
{
mx = 0;
interogare(a, b, 1, n, 1);
fout<<mx<<endl;
}
}
}