#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, s, i, j, otv = 0;
  cin >> a;
  vector<vector<long long> > vec(a + 10);
  vector<long long> v(a + 8, 0);
  long long num = 0;
  for (i = 0; i < a; i++) {
    long long x1, x2;
    cin >> x1 >> x2;
    if (x1 == -1)
      num = i;
    else
      vec[x1 - 1].push_back(i);
    v[i] = x2;
  }
  vector<long long> asd;
  for (i = 0; i < a; i++) {
    if (i != num)
      if (v[i] == 1) {
        long long pro = 0;
        for (j = 0; j < vec[i].size(); j++) {
          if (v[vec[i][j]] == 0) pro = 1;
        }
        if (pro == 0) asd.push_back(i + 1);
      }
  }
  if (asd.size() == 0)
    cout << -1;
  else {
    for (i = 0; i < asd.size(); i++) cout << asd[i] << " ";
  }
}
