#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  queue<int> prob;
  vector<bool> res_child(n + 1, false);
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    if (y == 1) {
      prob.push(i);
    } else if (x != -1) {
      res_child[x] = true;
    }
  }
  bool f = false;
  while (!prob.empty()) {
    int curr = prob.front();
    prob.pop();
    if (res_child[curr] == false) {
      cout << curr << " ";
      f = true;
    }
  }
  if (!f) {
    cout << -1 << endl;
  }
  return 0;
}
