#include <bits/stdc++.h>
using namespace std;

int tree[1 << 21];
int M = 1;

void ne(int v, int val) {
    v += M;
    tree[v] = val;
    v /= 2;
    while (v > 0) {
        tree[v] = max(tree[2 * v], tree[2 * v + 1]);
        v /= 2;
    }
}

int dp(int a, int b) {
    a += M;
    b += M;
    int res = max(tree[a], tree[b]);
    while (a / 2 != b / 2) {
        if (a % 2 == 0) res = max(res, tree[a + 1]);
        if (b % 2 == 1) res = max(res, tree[b - 1]);
        a /= 2;
        b /= 2;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m;
    cin>>n>>m;

    while (M <= n) M *= 2;

    for (int i = 1; i <= n; i++) {
        cin >> tree[M + i];
    }

    for (int i = M - 1; i >= 1; i--) {
        tree[i] = max(tree[2 * i], tree[2 * i + 1]);
    }

    while (m--) {
        int tajp, x, y;
        cin >> tajp >> x >> y;
        if (tajp == 1) {
            ne(x, y);
        } else {
            cout << dp(x, y) << "\n";
        }
    }
}