#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int c[100005], par[100005];
int d[100005];
set<int> second;
set<int> ans;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x >> a[i];
    par[i] = x;
    if (x == -1)
      ;
    else {
      if (a[i] == 1) c[x]++;
      d[x]++;
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (a[i] == 0) continue;
    if (c[i] == d[i]) second.insert(i);
  }
  if (second.empty()) {
    cout << -1;
    return 0;
  }
  while (!second.empty()) {
    int x = *second.begin();
    second.erase(second.begin());
    if (d[x] == c[x]) {
      ans.insert(x);
      int y = par[x];
      if (y != -1) {
        --d[y];
        d[y] += d[x];
        c[y] += c[x] - 1;
        d[x] = 0;
        c[x] = 0;
      }
    }
  }
  if (ans.empty()) {
    cout << -1;
    return 0;
  }
  for (auto &it : ans) cout << it << " ";
  return 0;
}
