#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int parent[n + 1];
  bool visited[n + 1];
  fill(visited, visited + n + 1, false);
  int children[n + 1];
  int c[n + 1];
  int cost[n + 1];
  fill(cost, cost + n + 1, 0);
  fill(children, children + n + 1, 0);
  int p, ci;
  for (int i = 1; i <= n; i++) {
    cin >> p >> ci;
    parent[i] = p;
    c[i] = ci;
    if (p != -1) {
      cost[p] += ci;
      children[p]++;
    }
  }
  priority_queue<int, vector<int>, greater<int>> q;
  for (int i = 1; i <= n; i++) {
    if (c[i] == 1 and c[parent[i]] == 1 and
        cost[parent[i]] == children[parent[i]]) {
      if (visited[parent[i]] == false) {
        q.push(parent[i]);
        visited[parent[i]] = true;
      }
      if (children[i] == 0) {
        if (visited[i] == false) {
          q.push(i);
          visited[i] = true;
        }
      }
    } else if (c[i] == 1 and children[i] == 0) {
      q.push(i);
    }
  }
  if (q.empty()) {
    cout << -1 << endl;
  }
  while (!q.empty()) {
    cout << q.top() << " ";
    q.pop();
  }
  return 0;
}
