func_code_string: #include <bits/stdc++.h>   using namespace std;   int dir4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};   int dir8[8][2] = {{-1, 0}, {1, 0},  {0, 1}, {0, -1},                     {-1, 1}, {1, -1}, {1, 1}, {-1, -1}};   int dir8h[8][2] = {{2, 1}, {-2, -1}, {-1, 2}, {1, -2},                      {1, 2}, {-2, 1},  {2, -1}, {-1, -2}};   int setbit(int num, int index, int value) {     return (value) ? (num | (1 << index)) : (num & ~(1 << index));   }   bool getbit(int num, int index) { return ((num >> index) & 1) == 1; }   int cntbits(int num) {     int cnt = 0;     while (num) {       if (num & 1) cnt++;       num /= 2;     }     return cnt;   }   double eps = 1e-8;   const int N = 1e5 + 100;   vector<int> v[N];   bool a[N], can[N];   int root;   bool dfs(int node, int pa) {     if (node != root && v[node].size() == 1) {       if (a[node]) {         can[node] = 1;         return 1;       } else {         can[node] = 0;         return 0;       }     } else {       if (a[node])         can[node] = 1;       else         can[node] = 0;       for (int i = 0; i < v[node].size(); i++) {         if (v[node][i] != pa) {           bool x = dfs(v[node][i], node);           if (!x) can[node] = 0;         }       }       if (a[node]) return 1;       return 0;     }   }   int main() {     ios_base::sync_with_stdio(false);     int n, p, c;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> p >> c;       a[i] = c;       if (p != -1)         v[p].push_back(i), v[i].push_back(p);       else         root = i;     }     bool cc = dfs(root, -1);     vector<int> res;     for (int i = 1; i <= n; i++) {       if (can[i]) res.push_back(i);     }     if (res.size() > 0) {       for (int i = 0; i < res.size(); i++) cout << res[i] <<    ;     } else       cout << -1;   }   