#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, u, c;
  cin >> n;
  vector<pair<int, int>> v[n + 1];
  int root;
  for (int i = 1; i <= n; i++) {
    cin >> u >> c;
    if (u == -1) {
      root = i;
      continue;
    }
    v[u].push_back(make_pair(i, c));
  }
  vector<int> ans;
  queue<pair<int, int>> q;
  q.push(make_pair(root, 0));
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    int i;
    int flag = 0;
    for (i = 0; i < v[p.first].size(); i++) {
      if (v[p.first][i].second != 1) {
        flag = 1;
        q.push(make_pair(v[p.first][i].first, v[p.first][i].second));
      } else {
        q.push(make_pair(v[p.first][i].first, v[p.first][i].second));
      }
    }
    if (p.second == 1 && flag == 0) ans.push_back(p.first);
  }
  if (ans.size() == 0) {
    cout << -1;
    return 0;
  }
  if (ans.size() == 1 && ans[0] == root) {
    cout << -1;
    return 0;
  }
  sort(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++) {
    if (ans[i] != root) cout << ans[i] << " ";
  }
  return 0;
}
