#include <bits/stdc++.h>
using namespace std;
struct tree {
  int C;
  int root;
  int number_of_branches;
  int *branches;
};
int main() {
  int c, p, n, i, j, r = 0;
  int start, D[100000] = {0}, k = 0;
  struct tree A[100000];
  cin >> n;
  for (i = 0; i < n; i++) {
    A[i].branches = new int[1];
    A[i].number_of_branches = 0;
  }
  for (i = 0; i < n; i++) {
    cin >> p >> c;
    if (p == -1) {
      start = i;
    } else {
      A[i].C = c;
      A[i].root = p - 1;
      A[p - 1].branches[A[p - 1].number_of_branches] = i;
      A[p - 1].number_of_branches++;
      A[p - 1].branches =
          (int *)realloc(A[p - 1].branches,
                         (A[p - 1].number_of_branches) * sizeof(struct tree));
    }
  }
  for (i = 0; i < n; i++) {
    if (A[i].C == 1) {
      k = 0;
      for (j = 0; j < A[i].number_of_branches; j++) {
        if (A[A[i].branches[j]].C == 1) {
          k++;
        }
      }
      if ((k == A[i].number_of_branches) ||
          (k == 0 && k == A[i].number_of_branches)) {
        cout << i + 1 << " ";
        r = 1;
      }
    }
  }
  if (r == 0) {
    cout << -1;
  }
  return 0;
}
