#include <bits/stdc++.h>
using namespace std;
int re[100005];
vector<int> s[100005];
int vis[100005];
int rot = 0;
int dfs(int p) {
  int ss = re[p];
  for (int i = 0; i < s[p].size(); i++) {
    ss += dfs(s[p][i]);
  }
  if (ss == s[p].size() + 1) {
    vis[p] = 1;
  }
  return re[p];
}
int main() {
  int n;
  scanf("%d", &n);
  int x, y;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    if (x == -1) {
      rot = i;
    } else {
      s[x].push_back(i);
      re[i] = y;
    }
  }
  dfs(rot);
  int bo = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) {
      bo++;
      printf("%d ", i);
    }
  }
  if (!bo) {
    printf("-1");
  }
  printf("\n");
  return 0;
}
