#include <bits/stdc++.h>
using namespace std;
int n, k, t;
priority_queue<int, vector<int>, greater<int> > p;
int c[100000 + 1];
int par[100000 + 1];
bool isRemove[100000 + 1];
int main() {
  cin >> n;
  for (int i = 0; i <= n; i++) isRemove[i] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> par[i] >> c[i];
    isRemove[i] &= c[i];
    if (par[i] != -1) {
      isRemove[par[i]] &= c[i];
    }
  }
  for (int i = 1; i <= n; i++) {
    if (isRemove[i]) p.push(i);
  }
  if (p.size() == 0) {
    cout << "-1\n";
  }
  while ((!p.empty())) {
    cout << p.top() << " ";
    p.pop();
  }
  return 0;
}
