#include <bits/stdc++.h>
using namespace std;
bitset<100001> c;
bool a = false;
int main() {
  int n;
  cin >> n;
  int x, y;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    if (x == -1) c[i] = 1;
    if (x != -1 && !y) {
      c[i] = 1;
      c[x] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!c[i]) {
      cout << i << " ";
      a = true;
    }
    if (i == n) cout << endl;
  }
  if (!a) cout << "-1" << endl;
  return 0;
}
