#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> parent(n);
  vector<vector<int> > children(n);
  vector<int> respect(n);
  for (int i = 0; i < n; i++) {
    cin >> parent[i];
    cin >> respect[i];
    if (parent[i] > 0) {
      parent[i]--;
      children[parent[i]].push_back(i);
    }
  }
  vector<int> unprotectedList;
  bool any = false;
  for (int i = 0; i < n; i++) {
    if (respect[i] != 0) {
      bool b = false;
      for (int j = 0; j < children[i].size(); j++) {
        if (respect[children[i][j]] == 0) {
          b = true;
        }
      }
      if (!b) {
        cout << i + 1 << " ";
        any = true;
      }
    }
  }
  if (!any) cout << -1;
  return 0;
}
