#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int> > a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    if (a[i].second == 0) {
      if (a[i].first != -1) {
        b[a[i].first - 1] = 1;
      }
    }
  }
  int col = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] == 0 && a[i].second == 1) {
      col++;
      cout << i + 1 << " ";
    }
  }
  if (col == 0) {
    cout << -1;
  }
  return 0;
}
