#include <bits/stdc++.h>
using namespace std;
int n;
int root = -1;
vector<int> child[100100];
int c[100100] = {0};
int rm[100100] = {0};
vector<int> lb;
void dfs(int u) {
  if (child[u].size() == 0) {
    rm[u] = c[u];
    if (rm[u]) lb.push_back(u);
    return;
  }
  bool has_good = false;
  for (int i = 0; i < child[u].size(); i++) {
    int v = child[u][i];
    dfs(v);
    if (!rm[v] && c[v] == 0) has_good = true;
  }
  if (c[u]) {
    if (has_good)
      rm[u] = 0;
    else {
      rm[u] = 1;
      lb.push_back(u);
    }
  } else {
    rm[u] = 0;
  }
}
int main() {
  cin >> n;
  int a, b;
  for (int i = 1; i <= n; i++) {
    cin >> a >> c[i];
    if (a < 0)
      root = i;
    else
      child[a].push_back(i);
  }
  dfs(root);
  sort(lb.begin(), lb.end());
  if (lb.size() == 0) {
    cout << -1;
  } else {
    for (int i = 0; i < lb.size(); i++) cout << lb[i] << " ";
  }
}
