#include <fstream>
#include <algorithm>
#include <iostream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
const int dim = 1e5 + 2;
int arb[4*dim], maxim;
int getMaxim(int nod, int left, int right, int pozS, int pozD) {
if(pozS > right || pozD < left) return -1;
if( pozS <= left && right <= pozD ) return arb[nod];
int mij = (left + right) / 2;
return max(getMaxim(nod * 2, left, mij, pozS, pozD), getMaxim(nod * 2 + 1, mij + 1, right, pozS, pozD));
}
void updateElement(int nod, int left, int right, int poz, int val) {
if(left == right) {
arb[nod] = val;
return;
}
int mij = (left + right) / 2;
if( mij >= poz )
updateElement(nod * 2, left, mij, poz, val);
else
updateElement(nod * 2 + 1, mij + 1, right, poz, val);
arb[nod] = max( arb[nod * 2], arb[nod * 2 + 1] );
}
int main() {
int n, m, op, a, b;
fin >> n >> m;
for(int i = 1; i <= n; i++) {
fin >> a;
updateElement(1, 1, n, i, a);
}
for(int i = 0; i < m; i++) {
fin >> op >> a >> b;
if(op == 0)
fout << getMaxim(1, 1, n, a, b) << '\n';
else
updateElement(1, 1, n, a, b);
}
return 0;
}