#include <bits/stdc++.h>
using namespace std;
vector<int> v[100005];
int c[100005];
int main() {
  int n, a, ch, index;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a >> ch;
    if (a != -1) {
      v[a].push_back(i);
      c[i] = ch;
    }
  }
  bool dec = false;
  set<int> s;
  for (int i = 1; i <= n; i++) {
    if (c[i] == 1) {
      if (v[i].size() == 0) {
        dec = true;
      } else {
        for (int j = 0; j < v[i].size(); j++) {
          index = v[i][j];
          if (c[index] == 1) {
            dec = true;
          } else {
            dec = false;
            break;
          }
        }
      }
      if (dec == true) {
        s.insert(i);
      }
    }
    dec = false;
  }
  if (s.empty()) {
    cout << "-1";
  } else {
    set<int>::iterator it;
    for (it = s.begin(); it != s.end(); it++) {
      cout << *it << " ";
    }
  }
  return 0;
}
