func_code_string: #include <bits/stdc++.h>   const int max_N = 1000 + 21;   int n, a[max_N], b[max_N], cnt[max_N];   std::vector<int> vec, _vec, ret[max_N];   int main() {     scanf( %d , &n);     for (int i = 1; i < n; ++i) {       scanf( %d%d , a + i, b + i);       if (a[i] > b[i]) std::swap(a[i], b[i]);       if (b[i] != n) return puts( NO ), 0;       ++cnt[a[i]];     }     for (int i = 1; i < n; ++i)       if (!cnt[i]) {         vec.push_back(i);       } else {         _vec.push_back(i);       }     std::reverse(vec.begin(), vec.end());     std::queue<int> Q;     int i = n - 1;     for (auto u : vec) {       while (i && i > u) {         if (cnt[i]--) {           while (cnt[i]--) Q.push(i);         }         --i;       }       if (Q.empty()) return puts( NO ), 0;       int v = Q.front();       ret[v].push_back(u);       Q.pop();     }     if (!Q.empty()) return puts( NO ), 0;     puts( YES );     for (auto u : _vec) {       if (ret[u].empty()) {         printf( %d %d n , u, n);       } else {         printf( %d %d n , ret[u][0], n);         for (auto i = 1; i < ret[u].size(); ++i) {           printf( %d %d n , ret[u][i - 1], ret[u][i]);         }         printf( %d %d n , ret[u].back(), u);       }     }     return 0;   }   