func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   vector<int> gr[(ll)(1e5 + 4)];   set<int> g[(ll)(1e5 + 4)];   bool vis[(ll)(1e5 + 4)];   int par[(ll)(1e5 + 4)], si[(ll)(1e5 + 4)];   int find(int no) {     if (par[no] != no) {       par[no] = find(par[no]);     }     return par[no];   }   void join(int a, int b) {     if (find(a) == find(b)) {       return;     }     int pa = par[a], pb = par[b];     if (si[pa] < si[pb]) {       swap(pa, pb);     }     si[pa] += si[pb];     si[pb] = 0;     par[pb] = pa;   }   void dfs(int node) {     cout << node <<    ;     vis[node] = 1;     for (int x : gr[node]) {       if (!vis[x]) {         dfs(x);       }     }   }   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int ar[n][3];       for (int i = 0; i < n - 2; i++) {         for (int j = 0; j < 3; j++) {           cin >> ar[i][j];           int a = ar[i][j];           g[a].insert(i);         }       }       set<pair<int, int>> sp;       for (int i = 1; i <= n; i++) {         par[i] = i, si[i] = 1;         sp.insert(make_pair(g[i].size(), i));       }       vector<int> qp;       while (sp.size()) {         auto p = *sp.begin();         sp.erase(sp.begin());         int ind = *g[p.second].begin();         qp.push_back(ind + 1);         for (int j = 0; j < 3; j++) {           int u = p.second;           int v = ar[ind][j];           if (find(u) != find(v)) {             gr[u].push_back(v);             gr[v].push_back(u);           }           join(u, v);           g[v].erase(ind);           if (g[v].size()) {             sp.insert(make_pair(g[v].size(), v));           }         }         while (sp.size() && sp.begin()->first > g[sp.begin()->second].size()) {           sp.erase(sp.begin());         }       }       for (int i = 1; i <= n; i++) {         if (gr[i].size() == 1 && vis[i] == 0) {           dfs(i);           cout <<   n ;         }       }       for (int i = 0; i < qp.size(); i++) {         cout << qp[i] <<    ;       }       cout <<   n ;       for (int i = 0; i <= n; i++) {         vis[i] = 0, gr[i].clear(), g[i].clear();       }     }   }   