#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> ADJ;
vector<int> P;
vector<int> C;
int N;
vector<vector<int>> D;
vector<int> ans;
int r = -1;
void dfs(int x) {
  int s1 = C[x];
  int c1 = 1;
  for (int i = 0; i < ADJ[x].size(); ++i) {
    dfs(ADJ[x][i]);
    int a = D[ADJ[x][i]][0];
    int b = D[ADJ[x][i]][1];
    if (!(a == 1)) {
      c1 = 0;
    }
  }
  D[x][0] = s1;
  D[x][1] = c1;
}
void solve() {
  for (int i = 0; i < N; ++i) {
    if (D[i][0] == 1 && D[i][1] == 1) {
      ans.push_back(i);
    }
  }
  if (ans.size() == 0) {
    cout << -1 << endl;
  } else {
    for (int i = 0; i < ans.size(); ++i) {
      cout << ans[i] + 1 << " ";
    }
    cout << endl;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  ADJ.resize(N);
  C.resize(N);
  D.resize(N);
  P.resize(N);
  for (int i = 0; i < N; ++i) {
    D[i].resize(2);
    int p, c;
    cin >> p >> c;
    C[i] = c;
    if (p != -1) {
      p--;
      ADJ[p].push_back(i);
      P[i] = p;
    } else {
      r = i;
      P[i] = -1;
    }
  }
  dfs(r);
  solve();
  return 0;
}
