#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long v[n + 1], m0[n + 1], m1[n + 1], root;
  for (long long i = 0; i <= n; i++) {
    v[i] = m0[i] = m1[i] = 0;
  }
  for (long long i = 1; i <= n; i++) {
    long long p, c;
    cin >> p >> c;
    if (p == -1) {
      root = i;
      continue;
    }
    v[i] = c;
    if (c == 0)
      m0[p]++;
    else
      m1[p]++;
  }
  long long flag = 0;
  for (long long i = 1; i <= n; i++) {
    if (v[i] && m0[i] == 0 && i != root) {
      cout << i << " ";
      flag = 1;
    }
  }
  if (!flag) cout << -1;
  return 0;
}
