#include <bits/stdc++.h>
using namespace std;
//sursa mai veche
int n;
array<int, 100002>a;
class stree {
public:
stree() {
l = r = nullptr;}
stree *l, *r;
int val;
~stree(){
delete l;delete r;
}
};
stree* T = new stree;
void init(stree *&cur, int l, int r)
{
if(l == r)
{
cur = new stree, cur->val = a[l];
return;
}
if(cur->l == NULL) cur->l = new stree, cur->r = new stree;
int m = (l + r) >> 1;
init(cur->l, l, m), init(cur->r, m + 1, r);
cur->val = max(cur->l->val, cur->r->val);
}
int get(stree *&cur, int x, int y, int l, int r)
{
if(x > r || l > y)
return 0;
if((l >= x && r <= y))
return cur->val;
int m = (l + r) >> 1;
return max(get(cur->l, x, y, l, m), get(cur->r, x, y, m + 1, r));
}
void update(stree *&cur, int pos, int val, int l, int r)
{
if(pos < l || pos > r)
return;
if(l == r)
{
cur->val = val;
return;
}
int m = (l + r) >> 1;
update(cur->l, pos, val, l, m), update(cur->r, pos, val, m + 1, r);
cur->val = max(cur->l->val, cur->r->val);
}
int main()
{
ifstream cin("arbint.in");
ofstream cout("arbint.out");
int m;
cin >> n >> m;
for(int i = 0; i < n; i++)
cin >> a[i];
init(T, 0, n - 1);
while(m--)
{
int op, x, y;
cin >> op >> x >> y;
if(op == 1)
update(T, x - 1, y, 0, n - 1);
else
cout << get(T, x - 1, y - 1, 0, n - 1) << '\n';
}
return 0;
}