#include <bits/stdc++.h>
using namespace std;
vector<int> child[100001];
set<int> ret;
int state[100001];
int parent[100001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  int p, c;
  int root = 0;
  for (int i = 1; i <= N; i++) {
    cin >> p >> c;
    if (p != -1) {
      child[p].push_back(i);
    } else {
      root = i;
    }
    state[i] = c;
  }
  queue<int> q;
  q.push(root);
  while (!q.empty()) {
    int here = q.front();
    q.pop();
    int point = 0;
    for (int i = 0; i < child[here].size(); i++) {
      if (state[child[here][i]] == 1) point++;
      q.push(child[here][i]);
    }
    if (state[here] == 1) {
      if (point == child[here].size()) {
        ret.insert(here);
      }
    }
  }
  if (ret.empty()) {
    cout << -1;
  } else {
    for (auto iter = ret.begin(); iter != ret.end(); ++iter) {
      cout << *iter << ' ';
    }
  }
  return 0;
}
