#include <bits/stdc++.h>
using namespace std;
const int Mx = 100005;
int N;
vector<int> g[Mx];
int ar[Mx];
void solve() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    int p, c;
    cin >> p >> c;
    if (p != -1) {
      g[p].push_back(i);
    }
    ar[i] = c;
  }
  vector<int> v;
  for (int i = 1; i <= N; i++) {
    if (ar[i]) {
      bool check = 1;
      for (auto it : g[i]) {
        if (ar[it] == 0) check = 0;
      }
      if (check) {
        v.push_back(i);
      }
    }
  }
  if (v.size() == 0)
    cout << -1 << endl;
  else {
    for (auto it : v) {
      cout << it << ' ';
    }
    cout << endl;
  }
}
int32_t main() {
  int tt;
  tt = 1;
  int cas = 1;
  while (tt--) {
    solve();
  }
}
