func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize(3)   using namespace std;   const int Mod = 1e9 + 7;   const int N = 5e5 + 100;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3f;   inline long long dpow(long long a, long long b) {     long long r = 1, t = a;     while (b) {       if (b & 1) r = (r * t) % Mod;       b >>= 1;       t = (t * t) % Mod;     }     return r;   }   inline long long fpow(long long a, long long b) {     long long r = 1, t = a;     while (b) {       if (b & 1) r = (r * t);       b >>= 1;       t = (t * t);     }     return r;   }   struct node {     int id, w;     bool operator<(const node &oth) const { return w > oth.w; }   };   struct Ask {     int op, x;   } qi[N];   pair<int, int> eg[N];   set<node> s[N];   int fa[N], sz[N], n, m, q;   int a[N];   bool vis[N];   stack<pair<int, int> > st;   void Init() {     for (int i = 1; i <= n; i++) fa[i] = i, sz[i] = 1;   }   int Find(int x) {     while (x != fa[x]) x = fa[x];     return x;   }   void Merge(int x, int y) {     x = Find(x);     y = Find(y);     if (x == y) {       st.push({0, 0});       return;     }     if (sz[x] > sz[y]) swap(x, y);     fa[x] = y;     st.push({x, y});     sz[y] += sz[x];     for (auto it : s[x]) s[y].insert(it);   }   void Cancle() {     int x = st.top().first, y = st.top().second;     st.pop();     if (!x && !y) return;     fa[x] = x;     sz[y] -= sz[x];     for (auto it : s[x]) {       if (s[y].find(it) != s[y].end()) s[y].erase(it);     }   }   int main() {     cin >> n >> m >> q;     Init();     for (int i = 1; i <= n; i++) scanf( %d , &a[i]), s[i].insert({i, a[i]});     for (int i = 1; i <= m; i++) scanf( %d %d , &eg[i].first, &eg[i].second);     for (int i = 1; i <= q; i++) {       scanf( %d %d , &qi[i].op, &qi[i].x);       if (qi[i].op == 2) vis[qi[i].x] = true;     }     for (int i = 1; i <= m; i++)       if (!vis[i]) Merge(eg[i].first, eg[i].second);     for (int i = q; i >= 1; i--) {       if (qi[i].op == 1) continue;       int u = eg[qi[i].x].first;       int v = eg[qi[i].x].second;       Merge(u, v);     }     for (int i = 1; i <= q; i++) {       int op = qi[i].op, x = qi[i].x;       if (op == 1) {         int u = Find(x);         while (!s[u].empty() && !a[s[u].begin()->id]) s[u].erase(s[u].begin());         if (s[u].empty())           puts( 0 );         else {           printf( %d n , s[u].begin()->w);           a[s[u].begin()->id] = 0;         }       } else         Cancle();     }     return 0;   }   