#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> del;
  int par[n + 1];
  bool chl[n + 1];
  memset(chl, false, sizeof(chl));
  for (i = 1; i <= n; i++) {
    cin >> k >> l;
    if (k == -1) {
      root = i;
      goto here;
    }
    if (l == 0) chl[k] = true;
    par[i] = l;
  here:;
  }
  for (i = 1; i <= n; i++) {
    if (i != root) {
      if (par[i] == 1 && !chl[i]) del.push_back(i);
    }
  }
  if (del.size() == 0) cout << -1 << endl;
  for (i = 0; i < del.size(); i++) cout << del[i] << " ";
  return 0;
}
