#include <bits/stdc++.h>
using namespace std;
int fx[] = {0, 1, 1, 1, 0, -1, -1, -1};
int fy[] = {1, 1, 0, -1, -1, -1, 0, 1};
int cnt[100005], top;
bool flag = false;
vector<int> data[100005], res;
void bfs() {
  queue<int> q;
  q.push(top);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    int tmp = 0;
    for (int i = 0; i < data[u].size(); i++) {
      int v = data[u][i];
      if (cnt[v] == 1 && cnt[u] == 1 && u != top) {
        tmp++;
      }
      q.push(v);
    }
    if (data[u].size() == 0) {
      if (u != top && cnt[u] == 1) {
        res.push_back(u);
        flag = true;
      }
    } else if (data[u].size() == tmp) {
      flag = true;
      res.push_back(u);
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int p;
    scanf("%d", &p);
    scanf("%d", &cnt[i]);
    if (p == -1)
      top = i;
    else
      data[p].push_back(i);
  }
  bfs();
  if (!flag)
    cout << "-1\n";
  else {
    sort(res.begin(), res.end());
    for (int i = 0; i < res.size(); i++) cout << res[i] << ' ';
    printf("\n");
  }
  return 0;
}
