#include <iostream>
#include <fstream>
#include <algorithm>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
const int N = 1e5 + 7;
int n, m, mx;
int v[N], nod[N * 2];
void updatemax(int poz, int st, int dr, int a, int b){
if(st == dr){
nod[poz] = b;
return ;
}
else{
int mij = st + (dr - st) / 2;
if(a <= mij) updatemax(poz * 2, st, mij, a, b);
else updatemax(poz * 2 + 1, mij + 1, dr, a, b);
nod[poz] = max(nod[poz * 2], nod[poz * 2 + 1]);
}
}
void maxAB(int poz, int st, int dr, int a, int b){
if(a <= st && b >= dr){
mx = max(mx, nod[poz]);
return ;
}
else{
int mij = st + (dr - st) / 2;
if(a <= mij) maxAB(poz * 2, st, mij, a, b);
if(b > mij) maxAB(poz * 2 + 1, mij + 1, dr, a, b);
}
}
int main()
{
fin >> n >> m;
for(int i = 1; i <= n; i++){
fin >> v[i];
updatemax(1, 1, n, i, v[i]);
}
while(m--){
int c, a, b;
fin >> c >> a >> b;
if(c == 1){
updatemax(1, 1, n, a, b);
} else{
mx = 0;
maxAB(1, 1, n, a, b);
fout << mx << "\n";
}
}
return 0;
}