#include <bits/stdc++.h>
using namespace std;
vector<int> v[100000];
int main() {
  int n, i, j, x, y, ans = 0;
  scanf("%d", &n);
  bool flag;
  int c[100000];
  int p[100000];
  for (i = 0; i < n; i++) {
    scanf("%d%d", &x, &c[i]);
    p[i] = x - 1;
    if (x > 0) {
      v[x - 1].push_back(i);
      v[i].push_back(x - 1);
    }
  }
  for (i = 0; i < n; i++) {
    if (!c[i]) continue;
    flag = true;
    for (j = 0; j < v[i].size(); j++)
      if (v[i][j] != p[i] && !c[v[i][j]]) {
        flag = false;
        break;
      }
    if (flag) {
      ans++;
      printf("%d ", i + 1);
    }
  }
  if (ans == 0) printf("-1\n");
  return 0;
}
