#include <bits/stdc++.h>
using namespace std;
int main() {
  const int MAX = 100000;
  int n;
  int p[MAX + 1];
  int c[MAX + 1];
  vector<int> child[MAX + 1];
  int root;
  vector<int> deletable;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i] >> c[i];
    if (p[i] == -1)
      root = i;
    else
      child[p[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    if (c[i] == 0) continue;
    if (child[i].empty()) {
      deletable.push_back(i);
    } else {
      int to_del = 1;
      for (vector<int>::iterator it = child[i].begin(); it != child[i].end();
           ++it) {
        to_del *= c[*it];
      }
      if (to_del == 1) deletable.push_back(i);
    }
  }
  if (deletable.empty()) {
    cout << "-1";
  } else {
    for (vector<int>::iterator it = deletable.begin(); it != deletable.end();
         ++it) {
      cout << *it << " ";
    }
  }
  cout << endl;
  return 0;
}
