#include <bits/stdc++.h>
using namespace std;
int c[1000010], clr[1000010], p[1000010], v[1000010], num[1000010];
vector<int> g[1000010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n + 1; ++i) {
    scanf("%d%d", &p[i], &c[i]);
    g[p[i]].push_back(i);
  }
  memset(v, 0, sizeof(v));
  vector<int> ans;
  priority_queue<int, vector<int>, greater<int> > q;
  for (int i = 1; i <= n; ++i) {
    clr[i] = 0;
    num[i] = g[i].size();
    for (int j = 0; j < g[i].size(); ++j) {
      int u = g[i][j];
      if (c[u]) {
        clr[i]++;
      }
    }
    if (c[i] == 1 && clr[i] == num[i]) {
      q.push(i);
      v[i] = 1;
      ans.push_back(i);
    }
  }
  if (ans.size()) {
    for (int t : ans) {
      printf("%d ", t);
    }
    printf("\n");
  } else
    printf("-1\n");
}
