func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     map<long long, vector<long long> > m;     map<long long, bool> v;     map<long long, long long> c;     vector<long long> b;     long long i, j, k, x, y, r;     for (i = 1; i <= n; i++) {       cin >> x >> y;       if (x == -1)         r = i;       else         m[x].push_back(i);       v[i] = false;       c[i] = y;     }     for (i = 1; i <= n; i++) {     }     queue<long long> q;     q.push(r);     long long f = 1;     while (!q.empty()) {       j = q.front();       if (c[j] == 1) f = 0;       for (i = 0; i < m[j].size(); i++) {         q.push(m[j][i]);         if (c[m[j][i]] != 1 and !f) {           f = 1;         }       }       if (f == 0) {         b.push_back(j);       }       f = 1;       q.pop();     }     if (b.size() == 0)       cout << -1;     else {       sort(b.begin(), b.begin() + b.size());       for (i = 0; i < b.size(); i++) {         cout << b[i] <<    ;       }     }   }   