func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   int getbit(T s, int i) {     return (s >> i) & 1;   }   template <class T>   T onbit(T s, int i) {     return s | (T(1) << i);   }   template <class T>   T offbit(T s, int i) {     return s & (~(T(1) << i));   }   template <class T>   int cntbit(T s) {     return __builtin_popcount(s);   }   template <class T>   T gcd(T a, T b) {     T r;     while (b != 0) {       r = a % b;       a = b;       b = r;     }     return a;   }   template <class T>   T lcm(T a, T b) {     return a / gcd(a, b) * b;   }   int test;   int n;   long long RR;   vector<int> KK[105];   long long HH(long long x) { return x * x * x * x * 3 + 425689 * x - 23156667; }   long long go(int par, int u) {     long long res = 32131;     for (int i = 0; i < (((int)(KK[u]).size())); ++i) {       int v = KK[u][i];       if (v == par) continue;       res += HH(go(u, v));     }     return res;   }   long long hash_tree(vector<pair<int, int> > V) {     int d[105];     memset(d, 0, sizeof(d));     for (int i = (1); i <= (n); ++i)       if (((int)(KK[i]).size())) KK[i].clear();     for (int i = 0; i < (((int)(V).size())); ++i) {       int u = V[i].first, v = V[i].second;       KK[u].push_back(v);       KK[v].push_back(u);       d[u]++;       d[v]++;     }     int number = 0;     int que[105], size = 0, que1[105], size1 = 0;     for (int i = (1); i <= (n); ++i) {       if (d[i] >= 1) number++;       if (d[i] == 1) que[size++] = i;     }     while (true) {       if (size <= 2) break;       size1 = 0;       for (int t = 0; t < (size); ++t) {         que1[size1++] = que[t];       }       size = 0;       for (int t = 0; t < (size1); ++t) {         int u = que1[t];         for (int j = 0; j < (((int)(KK[u]).size())); ++j) {           int v = KK[u][j];           d[v]--;           if (d[v] == 1) {             que[size++] = v;           }         }       }     }     long long res = 325843;     vector<long long> Vll;     for (int i = 0; i < (size); ++i) {       Vll.push_back(go(0, que[i]));     }     sort((Vll).begin(), (Vll).end());     for (int i = 0; i < (size); ++i) {       res = res * 1000000007 + Vll[i];     }     return res;   }   long long hash_forest(vector<pair<int, int> > V) {     bool flag[105];     vector<int> VV[105];     memset(flag, 0, sizeof(flag));     for (int i = 0; i < (((int)(V).size())); ++i) {       int u = V[i].first, v = V[i].second;       VV[u].push_back(v);       VV[v].push_back(u);     }     vector<long long> Vll;     for (int i = 1; i <= n; i++)       if (!flag[i]) {         flag[i] = 1;         int que[105], size = 0;         que[size++] = i;         vector<pair<int, int> > temp;         for (int t = 0; t < (size); ++t) {           int u = que[t];           for (int j = 0; j < (((int)(VV[u]).size())); ++j) {             int v = VV[u][j];             if (!flag[v]) {               flag[v] = 1;               que[size++] = v;               temp.push_back(make_pair(u, v));             }           }         }         Vll.push_back(hash_tree(temp));       }     sort((Vll).begin(), (Vll).end());     long long res = 132435;     for (int i = 0; i < ((int)(Vll).size()); i++) res = res * 1000000007 + Vll[i];     return res;   }   long long hash_alot(vector<vector<pair<int, int> > > V) {     vector<long long> Vll;     for (int i = 0; i < ((int)(V).size()); i++) {       Vll.push_back(hash_forest(V[i]));     }     sort((Vll).begin(), (Vll).end());     long long res = 132435;     for (int i = 0; i < ((int)(Vll).size()); i++) res = res * 1000000007 + Vll[i];     return res;   }   bool calcu(vector<pair<int, int> > V) {     vector<vector<pair<int, int> > > VV;     for (int i = (1); i <= (n); ++i) {       vector<pair<int, int> > temp;       for (int j = 0; j < (((int)(V).size())); ++j) {         if (V[j].first != i && V[j].second != i) {           temp.push_back(V[j]);         }       }       VV.push_back(temp);     }     long long res = hash_alot(VV);     return res == RR;   }   void cal(vector<pair<int, int> > V) {     bool have[105];     memset(have, 0, sizeof(have));     for (int i = 0; i < (((int)(V).size())); ++i) {       int u = V[i].first, v = V[i].second;       have[u] = 1;       have[v] = 1;     }     for (int i = (1); i <= (n); ++i)       if (!have[i]) {         for (int j = (1); j <= (n); ++j)           if (j != i) {             vector<pair<int, int> > VV;             VV = V;             VV.push_back(make_pair(i, j));             if (calcu(VV)) {               cout <<  YES n ;               for (int t = 0; t < (((int)(VV).size())); ++t) {                 cout << VV[t].first <<     << VV[t].second <<   n ;               }               return;             }           }       }     cout <<  NO n ;   }   void solve() {     cin >> n >> n;     vector<vector<pair<int, int> > > V;     for (int i = 0; i < (n); ++i) {       int num;       cin >> num;       vector<pair<int, int> > temp;       for (int j = 0; j < (num); ++j) {         int u, v;         cin >> u >> v;         temp.push_back(make_pair(u, v));       }       V.push_back(temp);     }     RR = hash_alot(V);     for (int i = 0; i < n; i++) {       if (((int)(V[i]).size()) == n - 2) {         cal(V[i]);         break;       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> test;     for (int itest = 0; itest < (test); ++itest) {       solve();     }     return 0;   }   