#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  bool valid[n + 1];
  map<int, bool> mp;
  memset(valid, true, sizeof(valid));
  for (int i = 1; i <= n; i++) {
    int c, p;
    cin >> p >> c;
    if (c == 1 && valid[i]) {
      mp[i] = true;
    } else if (c == 0) {
      valid[p] = false;
      if (mp.find(p) != mp.end()) mp.erase(p);
    }
  }
  if (mp.size()) {
    vector<int> a;
    map<int, bool>::iterator itr;
    for (itr = mp.begin(); itr != mp.end(); itr++) a.push_back(itr->first);
    sort(a.begin(), a.end());
    for (int i = 0; i < a.size(); i++) cout << a[i] << " ";
    cout << "\n";
  } else
    cout << "-1\n";
}
