func_code_string: #include <bits/stdc++.h>   using namespace std;   const int mod = 1000000000 + 7;   const int MAX = 100000;   map<pair<string, int>, int> F;   vector<pair<string, int>> v, ans;   pair<string, int> q;   set<string> s;   int n;   vector<int> g[300000];   vector<int> S[300000];   bool used[300000];   bool cmp(int i1, int i2) { return v[i1].second > v[i2].second; }   bool qw(int i1, int i2) { return i1 > i2; }   int main() {     cin >> n;     for (int i = (0); i < (n); i++) {       cin >> q.first >> q.second;       if (!F.count(q)) F[q] = v.size(), v.push_back(q);       int V = F[q];       int k;       cin >> k;       for (int j = (0); j < (k); j++) {         cin >> q.first >> q.second;         if (!F.count(q)) F[q] = v.size(), v.push_back(q);         g[V].push_back(F[q]);       }     }     S[0].push_back(0);     used[0] = 1;     s.insert(v[0].first);     for (int i = (0); i < (n); i++) {       sort(S[i].begin(), S[i].end(), cmp);       for (int j = (0); j < (S[i].size()); j++) {         if (i && !s.count(v[S[i][j]].first)) {           s.insert(v[S[i][j]].first);           ans.push_back(v[S[i][j]]);         } else if (i)           continue;         for (int k = (0); k < (g[S[i][j]].size()); k++)           if (!used[g[S[i][j]][k]])             S[i + 1].push_back(g[S[i][j]][k]), used[g[S[i][j]][k]] = 1;       }     }     sort(ans.begin(), ans.end());     cout << ans.size() <<   n ;     for (int i = (0); i < (ans.size()); i++)       cout << ans[i].first <<     << ans[i].second << endl;     return 0;   }   