#include <bits/stdc++.h>
using namespace std;
using v_i = vector<int>;
int graph[100002];
int c[100002];
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    if (y == 0) c[i] = 1;
    if (y == 0 && x != -1) {
      c[x] = 1;
    }
  }
  bool flag = true;
  for (int i = 1; i <= n; i++) {
    if (c[i] != 1) {
      flag = false;
      cout << i << " ";
    }
  }
  if (flag) cout << -1;
}
int main() {
  solve();
  return 0;
}
