#include <bits/stdc++.h>
using namespace std;
template <typename T>
int remin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
int remax(T& a, const T& b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}
const int NN = 100005;
int N;
int tree[NN];
set<int> children[NN];
int is_respecting[NN];
void remove(int k) {
  for (auto el : children[k]) {
    tree[el] = tree[k];
    children[k].insert(el);
  }
  children[k].erase(k);
}
bool can_remove(int k) {
  if (is_respecting[k]) return false;
  for (auto el : children[k]) {
    if (is_respecting[el]) return false;
  }
  return true;
}
int main(int argc, const char** argv) {
  int p, v;
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) tree[i] = i;
  for (int i = 1; i <= N; ++i) {
    scanf("%d%d", &p, &v);
    if (p == -1) {
      tree[i] = i;
    } else {
      tree[i] = p;
      children[p].insert(i);
    }
    is_respecting[i] = !v;
  }
  bool isok = false;
  for (int i = 1; i <= N; ++i) {
    if (can_remove(i)) {
      remove(i);
      printf("%d ", i);
      isok = true;
    }
  }
  if (!isok) {
    printf("-1\n");
  } else {
    printf("\n");
  }
  return 0;
}
