func_code_string: #include <bits/stdc++.h>   using namespace std;   typedef int ll;   const ll MAX = 5e5 + 100;   const ll inf = 1e9;   const ll mod = 1e9 + 7;   bool go[MAX];   ll p[MAX], dsu[MAX], n, m;   pair<ll, ll> e[MAX];   vector<pair<ll, ll> > Querie;   ll ans[MAX];   ll vertex;   vector<ll> adj[MAX];   vector<ll> querys_on_graph[MAX];   ll find(ll u) { return (dsu[u] == u ? u : dsu[u] = find(dsu[u])); }   void uni(ll u, ll v) {     ll x = find(u), y = find(v);     if (x == y) return;     vertex++;     adj[vertex].push_back(x);     adj[vertex].push_back(y);     dsu[y] = vertex;     dsu[x] = vertex;   }   ll L[MAX], R[MAX], pos[MAX], leaf = 1, val[MAX], val_to_u[MAX];   ll tree[MAX * 2];   void dfs(ll u) {     L[u] = inf;     for (ll v : adj[u]) {       dfs(v);       L[u] = min(L[u], L[v]);       R[u] = max(R[u], R[v]);     }     if (adj[u].size() == 0) {       pos[u] = leaf++;       L[u] = R[u] = pos[u];       val[pos[u]] = p[u];     }   }   void build(ll node, ll l, ll r) {     if (l == r) {       tree[node] = val[l];       return;     }     ll mid = (l + r) >> 1;     build(node << 1, l, mid);     build(node << 1 | 1, mid + 1, r);     tree[node] = max(tree[node << 1], tree[node << 1 | 1]);   }   void update(ll node, ll l, ll r, ll x) {     if (l == r) {       tree[node] = 0;       return;     }     ll mid = (l + r) >> 1;     if (x <= mid)       update(node << 1, l, mid, x);     else       update(node << 1 | 1, mid + 1, r, x);     tree[node] = max(tree[node << 1], tree[node << 1 | 1]);   }   ll query(ll node, ll l, ll r, ll i, ll j) {     if (j < l || r < i) return 0;     if (i <= l && r <= j) {       return tree[node];     }     ll mid = (l + r) >> 1;     return max(query(node << 1, l, mid, i, j),                query(node << 1 | 1, mid + 1, r, i, j));   }   void dfs_go(ll u) {     for (ll v : adj[u]) {       dfs_go(v);     }     sort(querys_on_graph[u].begin(), querys_on_graph[u].end());     for (ll it : querys_on_graph[u]) {       ll answer = query(1, 1, n, L[u], R[u]);       ans[it] = answer;       if (answer != 0) {         update(1, 1, n, pos[val_to_u[answer]]);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ll q, t, u;     cin >> n >> m >> q;     for (ll i = 1; i < (ll)n + 1; i++) cin >> p[i], val_to_u[p[i]] = i;     for (ll i = 1; i < (ll)m + 1; i++) cin >> e[i].first >> e[i].second;     for (ll i = 0; i < (ll)q; i++) {       cin >> t >> u;       if (t == 2) go[u] = 1;       Querie.push_back({t, u});     }     for (ll i = 1; i < (ll)2 * n + 5; i++) dsu[i] = i;     for (ll i = 1; i < (ll)m + 1; i++)       if (!go[i]) Querie.push_back({2, i});     vertex = n;     vector<ll> ask;     reverse(Querie.begin(), Querie.end());     for (pair<ll, ll> it : Querie) {       if (it.first == 2) {         uni(e[it.second].first, e[it.second].second);       } else {         ask.push_back(find(it.second));       }     }     vertex++;     for (ll i = 1; i < (ll)vertex; i++)       if (find(i) == i) adj[vertex].push_back(find(i));     dfs(vertex);     build(1, 1, n);     reverse(ask.begin(), ask.end());     for (ll i = 0; i < (ll)ask.size(); i++) {       ll u = ask[i];       ll answer = query(1, 1, n, L[u], R[u]);       cout << answer << endl;       if (answer != 0) {         update(1, 1, n, pos[val_to_u[answer]]);       }     }     return 0;   }   