#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> g[n + 1];
  queue<int> q;
  int b[n + 1];
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a >> b[i];
    if (a == -1) continue;
    g[a].push_back(i);
    if (b[i] == 1) q.push(i);
  }
  vector<int> ans;
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    int f = 1;
    for (int v : g[p]) {
      if (b[v] != 1) {
        f = 0;
        break;
      }
    }
    if (f) ans.push_back(p);
  }
  int z = ans.size();
  if (z == 0)
    cout << -1;
  else {
    for (int x : ans) cout << x << " ";
  }
  return 0;
}
