#include <bits/stdc++.h>
using namespace std;
int n, can[200100], P;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) can[i] = 1;
  for (int i = 1; i <= n; ++i) {
    int p, c;
    scanf("%d %d", &p, &c);
    if (c == 0) {
      if (p >= 0) can[p] = 0;
      can[i] = 0;
    }
  }
  for (int i = 1; i <= n; ++i)
    if (can[i]) printf("%d ", i), P = 1;
  if (!P) printf("-1");
}
