#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> parent(n + 1), respect(n + 1), child[n + 1];
  long long root;
  for (long long i = 1; i <= n; i++) {
    long long a, b;
    cin >> a >> b;
    parent[i] = a;
    respect[i] = b;
    if (a != -1)
      child[a].push_back(i);
    else
      root = i;
  }
  vector<long long> st, mark(n + 1, 0);
  queue<long long> q;
  q.push(root);
  while (!q.empty()) {
    long long t = q.front();
    q.pop();
    mark[t] = 1;
    if (respect[t] == 1) {
      long long f = 0;
      for (long long i = 0; i < child[t].size(); i++) {
        long long c = child[t][i];
        if (respect[c] == 0) f++;
      }
      if (f == 0) {
        st.push_back(t);
      }
    }
    for (long long i = 0; i < child[t].size(); i++) {
      long long c = child[t][i];
      if (mark[c] == 0) q.push(c);
    }
  }
  if (st.size() != 0) {
    sort(st.begin(), st.end());
    for (long long i = 0; i < st.size(); i++) cout << st[i] << " ";
  } else
    cout << -1 << endl;
}
