#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, i, j, k, l, root;
  cin >> n;
  vector<int> vec[n + 5];
  vector<int> del;
  int par[n + 5], chl[n + 5];
  bool chhl[n + 1];
  memset(chhl, false, sizeof(chhl));
  for (i = 1; i <= n; i++) chl[i] = 1;
  for (i = 1; i <= n; i++) {
    cin >> k >> l;
    if (k != -1)
      vec[k].push_back(i);
    else
      root = i;
    par[i] = l;
    if (k == -1) par[i] = 0;
  }
  for (i = 1; i <= n; i++) {
    for (j = 0; j < vec[i].size(); j++) {
      k = vec[i][j];
      if (par[k] == 0) {
        chl[i] = 0;
        break;
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (i != root) {
      if (par[i] == 1 && chl[i] == 1) del.push_back(i);
    }
  }
  if (del.size() == 0) cout << -1 << endl;
  for (i = 0; i < del.size(); i++) cout << del[i] << " ";
  cout << endl;
  return 0;
}
