func_code_string: #include <bits/stdc++.h>   using namespace std;   pair<int, int> nextInt(const string &s, int ind) {     int ret = 0;     while (ind < s.length() && s[ind] >=  0  && s[ind] <=  9 ) {       ret = ret * 10 + ((int)s[ind] - 48);       ind++;     }     return make_pair(ret, ind);   }   int main() {     int counti = 0;     int n;     int w[1024];     vector<vector<int> > input;     for (int i = 0; i < 1024; i++) {       w[i] = 0;     }     cin >> n;     counti = n;     input.resize(n + 10);     for (int i = 1; i <= n; i++) {       input[i].push_back(-1);       string in;       cin >> in;       if (nextInt(in, 0).first == n - 1) {         w[i] = 1;       } else {         int ind = 0;         while (in[ind]) {           if (in[ind] >=  0  && in[ind] <=  9 ) {             pair<int, int> ret = nextInt(in, ind);             ind = ret.second;             input[i].push_back(ret.first);           } else if (in[ind] ==  - ) {             input[i].push_back(-1);             ind++;             counti++;           } else             ind++;         }       }     }     int weight = 1;     vector<pair<int, int> > ans;     while (weight < n) {       for (int i = 1; i <= n; i++) {         for (int j = 1; j < input[i].size(); j++)           if (input[i][j - 1] == -1 && input[i][j] == weight)             for (j = j + 1; j < input[i].size() && input[i][j] != -1; j++)               if (w[input[i][j]] == weight) {                 ans.push_back(make_pair(i, input[i][j]));                 if (w[i] == 0)                   w[i] = weight + 1;                 else                   w[i] += weight;               }       }       weight++;     }     if (n == 2) {       cout <<  1  << endl;       cout <<  1 2 ;       return 0;     }     if (ans.size() != n - 1 || counti != (n - 1) * 2) {       cout << -1;       return 0;     }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); i++)       cout << ans[i].first <<     << ans[i].second << endl;     return 0;   }   