#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {}
long long t, d, n, m, q;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  long long TestCases = 1;
  while (TestCases--) {
    cin >> n;
    map<long long, vector<long long> > adj;
    long long c[100005], pa[100005];
    for (long long i = (1); i < (n + 1); ++(i)) {
      cin >> q >> c[i];
      if (q != -1) {
        adj[q].push_back(i);
        pa[i] = q;
      }
    }
    priority_queue<long long> pq;
    for (long long i = (1); i < (n + 1); ++(i))
      if (c[i]) {
        bool val = true;
        for (auto x : adj[i])
          if (val) val = val and c[x];
        if (val) pq.push(-i);
      }
    if (pq.size() == 0) {
      cout << -1;
      return 0;
    }
    while (!pq.empty()) cout << -pq.top() << ' ', pq.pop();
  }
  return 0;
}
