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