#include <bits/stdc++.h>
using namespace std;
int n, y;
bool r = 0;
int main() {
  cin >> n;
  vector<bool> a(n + 1);
  for (int i = 1; i <= n; i++) {
    int v, r;
    cin >> v >> r;
    if (v == -1) {
      y = i;
      continue;
    }
    if (!r) {
      a[v] = 1;
      a[i] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!a[i] && i != y) {
      r = 1;
      cout << i << " ";
    }
  }
  if (!r) {
    cout << -1 << "\n";
  } else {
    cout << "\n ";
  }
  return 0;
}
