#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> bres(n, -1);
  vector<int> p(n, 0);
  vector<int> c(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> p[i] >> c[i];
    p[i]--;
  }
  for (int i = 0; i < n; i++) {
    if (c[i] == 0) {
      int par = p[i];
      while (par != -2) {
        if (bres[par] == 1) break;
        bres[par] = 1;
        par = p[par];
        break;
      }
    }
  }
  set<int> num;
  for (int i = 0; i < n; i++) {
    if (bres[i] == -1 && c[i] == 1) num.insert(i + 1);
  }
  if (num.size() == 0) {
    cout << -1 << endl;
    return 0;
  }
  while (num.size() > 0) {
    cout << *num.begin() << " ";
    num.erase(num.begin());
  }
  cout << endl;
  return 0;
}
