#include <bits/stdc++.h>
using namespace std;
vector<int> v[100008];
vector<bool> gg(100008);
set<int> st;
void bfs(int start) {
  queue<int> q;
  q.push(start);
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    bool f = 1;
    if (gg[p] == 0) f = 0;
    for (int i = 0; i < v[p].size(); i++) {
      q.push(v[p][i]);
      if (gg[v[p][i]] == 0) f = 0;
    }
    if (f == 1) st.insert(p);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int start;
  for (int i = 1; i <= n; i++) {
    int a, b;
    cin >> a >> b;
    gg[i] = b;
    if (a != -1) v[a].push_back(i);
    if (a == -1) start = i;
  }
  bfs(start);
  if (st.size() == 0)
    cout << -1;
  else
    for (auto i : st) cout << i << " ";
  return 0;
}
