#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 10;
int c[MAX], p[MAX], s[MAX], r[MAX];
int n, root;
vector<int> g[MAX];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i] >> c[i];
    if (p[i] == -1)
      root = i;
    else {
      g[p[i]].push_back(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (auto u : g[i]) {
      s[i]++;
      r[i] += c[u];
    }
  }
  bool any = false;
  for (int i = 1; i <= n; i++) {
    if (r[i] == s[i] && c[i] == 1) {
      any = true;
      s[p[i]] += max(s[i] - 1, 0);
      r[p[i]] += max(r[i] - 1, 0);
      cout << i << " ";
    }
  }
  cout << (any ? "\n" : "-1\n");
  return 0;
}
