#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, p, c;
  cin >> n;
  bool fix[n + 1], flag = false;
  memset(fix, 0, n + 1);
  for (i = 1; i <= n; i++) {
    cin >> p >> c;
    if (c == 0) fix[i] = fix[p] = 1;
  }
  for (i = 1; i <= n; i++) {
    if (!fix[i]) {
      cout << i << " ";
      flag = true;
    }
  }
  if (!flag) cout << -1 << endl;
  return 0;
}
