#include <bits/stdc++.h>
using namespace std;
long long int N;
long long int arr[100005] = {};
int main() {
  scanf("%lld", &N);
  long long int parentIdx, respect;
  for (long long int i = 0; i < N; i++) {
    arr[i] = 1;
  }
  for (long long int i = 0; i < N; i++) {
    scanf("%lld", &parentIdx), scanf("%lld", &respect);
    if (parentIdx == -1) {
      arr[i] = respect;
    } else {
      arr[parentIdx - 1] *= respect;
      arr[i] *= respect;
    }
  }
  long long int t = 0;
  for (long long int i = 0; i < N; i++) {
    if (arr[i] == 1) {
      t++;
      cout << i + 1 << " ";
    }
  }
  if (t == 0) cout << -1;
  cout << endl;
  return 0;
}
