#include <bits/stdc++.h>
using namespace std;
struct node {
  int number = 0, parent = .0;
  bool flag = false;
  int child = 0;
  int visited = 0;
  int notAngry = 0;
  void set(int _number, bool _flag, int _parent) {
    number = _number;
    flag = _flag;
    parent = _parent;
  }
};
int main() {
  int n;
  cin >> n;
  vector<node> tree;
  tree.resize(n);
  for (int i = 0; i < n; i++) {
    int par;
    bool flag;
    cin >> par >> flag;
    par--;
    tree[i].set(i, flag, par);
    if (par != -2) tree[par].child += 1;
  }
  queue<int> leaves;
  for (auto i : tree) {
    if (i.child == 0) leaves.push(i.number);
  }
  vector<int> ans;
  while (!leaves.empty()) {
    int leave = leaves.front();
    leaves.pop();
    if (tree[leave].parent == -2) break;
    int par = tree[leave].parent;
    if (tree[leave].flag && tree[leave].notAngry == 0) {
      ans.push_back(leave);
      tree[par].child -= 1;
    } else {
      if (!tree[leave].flag) tree[par].notAngry += 1;
      tree[par].visited += 1;
    }
    if (tree[par].child == tree[par].visited) leaves.push(par);
  }
  sort(ans.begin(), ans.end());
  if (ans.empty())
    cout << -1 << endl;
  else {
    for (auto i : ans) cout << i + 1 << " ";
    cout << endl;
  }
}
