#include <bits/stdc++.h>
#define Nmax 100005
#define Arbmax 262145
#define Lmax 18
using namespace std;
int n, op, arb[Arbmax], big;
ifstream f("arbint.in");
ofstream g("arbint.out");
void updateTree(int node, int val, int st, int dr, int a, int b)
{
if (a <= st && b >= dr) {
arb[node] = val;
return;
}
int mid = (st + dr) / 2;
if (a <= mid)
updateTree(2 * node, val, st, mid, a, b);
if (mid < b)
updateTree(2 * node + 1, val, mid + 1, dr, a, b);
arb[node] = max(arb[2*node], arb[2*node + 1]);
}
void read()
{
f >> n >> op;
}
void ask(int node, int st, int dr, int a, int b)
{
if (a <= st && b >= dr) {
big = max(big, arb[node]);
return;
}
int mid = (st + dr) / 2;
if (a <= mid)
ask(2*node, st, mid, a, b);
if (mid < b)
ask(2*node + 1, mid + 1, dr, a, b);
}
void constructTree()
{
int val;
for (int i = 1; i <= n; ++i) {
f >> val;
updateTree(1, val, 1, n, i, i);
}
int c, x, y;
for (int i = 1; i <= op; ++i) {
f >> c >> x >> y;
if (!c) {
big = -1;
ask(1, 1, n, x, y);
g << big << "\n";
}
else
updateTree(1, y, 1, n, x, x);
}
}
int main()
{
read();
constructTree();
return 0;
}