#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll = long long;
const ll N = 2e5 + 9;
struct Segment_Tree {
pair<ll, ll> t[4 * N];
pair<ll, ll> merge(auto &l, auto &r) { // <== Change this function
return {min(l.second, r.second), max(l.first, r.first)};
}
void build(ll node, ll st, ll en, vector<ll> &arr) { //=> O(N)
if (st == en) {
t[node] = {arr[st], arr[st]};
return;
}
ll mid = (st + en) >> 1;
build(node << 1, st, mid, arr); // divide left side
build(node << 1 | 1, mid + 1, en, arr); // divide right side
// Merging left and right portion
auto &Cur = t[node];
auto &Left = t[node << 1];
auto &Right = t[node << 1 | 1];
Cur = merge(Left, Right);
return;
}
void update(ll node, ll st, ll en, ll idx, ll val) { //=> O(log n)
if (st == en) {
t[node] = {val, val};
return;
}
ll mid = (st + en) >> 1;
if (idx <= mid) update(node << 1, st, mid, idx, val);
else update(node << 1 | 1, mid + 1, en, idx, val);
// Merging left and right portion
auto &Cur = t[node];
auto &Left = t[node << 1];
auto &Right = t[node << 1 | 1];
Cur = merge(Left, Right);
return;
}
} st1;
int main() {
ios::sync_with_stdio(false); cin.tie(0);
ll n, qry;
cin >> n >> qry;
vector<ll> arr(n + 1);
for(ll i = 1; i <= n; i++) cin >> arr[i];
st1.build(1, 1, n, arr);
ll i, v, q;
while(qry--) {
cin >> i >> v >> q;
st1.update(1, 1, n, i, v);
if(q) cout << st1.t[1].second << endl;
else cout << st1.t[1].first << endl;
}
return 0;
}