#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
int n, mark[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1, x, y; i <= n; ++i) {
    scanf("%d%d", &x, &y);
    if (x == -1) {
      mark[i] = 1;
      continue;
    }
    if (y == 0) mark[x] = 1, mark[i] = 1;
  }
  bool flag = false;
  for (int i = 1; i <= n; ++i)
    if (!mark[i]) printf("%d ", i), flag = true;
  if (flag == false) printf("-1");
  return 0;
}
