#include <bits/stdc++.h>
using namespace std;
map<int, vector<int> > g;
long long int val[1000010], v[1000010], done[1000010];
long long int mi;
int root;
priority_queue<int, vector<int>, greater<int> > q;
long long int id[1000010];
int rot(int x) {
  while (x != id[x]) {
    id[x] = id[id[x]];
    x = id[x];
  }
  return x;
}
void union1(int p, int q) {
  int p1 = rot(p);
  int q1 = rot(q);
  id[q1] = p1;
}
void dfs(int s) {
  v[s] = 1;
  int ans = val[s];
  for (int i = 0; i < g[s].size(); i++) {
    int c = g[s][i];
    if (v[c] == 0) {
      ans = ans & val[c];
      dfs(c);
    }
  }
  done[s] = ans;
  return;
}
void dfs2(int s) {
  v[s] = 1;
  for (int i = 0; i < g[s].size(); i++) {
    int c = g[s][i];
    if (v[c] == 0) {
      if (done[s] && done[c]) {
        union1(s, c);
      }
      dfs2(c);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) id[i] = i;
  for (int i = 1; i <= n; i++) {
    long long int x, c;
    cin >> x >> c;
    if (x != -1)
      g[x].push_back(i);
    else
      root = i;
    val[i] = c;
  }
  vector<int> ans;
  dfs(root);
  for (int i = 1; i <= n; i++) v[i] = 0;
  dfs2(root);
  for (int i = 1; i <= n; i++) {
    if (done[i] == 1) {
      ans.push_back(i);
    }
  }
  if (ans.size()) {
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  } else
    cout << -1;
}
