#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e5 + 3;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    long long n;
    cin >> n;
    map<long long, vector<pair<long long, long long>>> graph;
    set<long long> s;
    long long p, c;
    for (long long i = 1; i < n + 1; i++) {
      cin >> p >> c;
      graph[p].push_back({i, c});
      if (c == 1) s.insert(i);
    }
    long long k = 0, cnt, x;
    for (auto it : s) {
      x = graph[it].size();
      long long cnt = 0;
      for (auto ch : graph[it]) {
        if (ch.second == 1) {
          cnt++;
        }
      }
      if (cnt == x) {
        k = 1;
        cout << it << " ";
      }
    }
    if (k == 0) cout << "-1";
  }
  return 0;
}
